btubbs / datetime

A Go (golang) library for parsing most ISO8601 timestamps
MIT License
24 stars 0 forks source link

Support comma as decimal separator #1

Open yuzhichang opened 3 years ago

yuzhichang commented 3 years ago
$ date --iso-8601=ns
2021-04-23T09:17:28,235575783+08:00    //on Ubuntu 20.4
2021-04-23T09:18:11,357706892+0800     //on CentOS 7.6

This library failed to parse these formats.

btubbs commented 3 years ago

Interesting. I've never seen commas used for the nanosecond part. Is that in the iso8601 spec?

btubbs commented 3 years ago

Seems like it is. But this library is similar to most in not supporting the comma. Found discussion here. https://stackoverflow.com/questions/20699705/why-does-the-iso-8601-specification-appear-to-be-universally-ignored-when-it-com

I'll update this issue to be a feature request for supporting commas as an additional decimal separator.

yuzhichang commented 3 years ago

@btubbs go 1.17 supports commas

The package now accepts comma "," as a separator for fractional seconds when parsing and formatting time. For example, the following time layouts are now accepted:

2006-01-02 15:04:05,999999999 -0700 MST
Mon Jan _2 15:04:05,000000 2006
Monday, January 2 15:04:05,000 2006