Hi there!
I recently noticed a discrepancy in how Timex formats its ISO-8601 datetime strings. It looks like its a mixture of both the basic and extended formats. Basic format (YYYYMMDDThhmmss±hhmm e.g. 19850412T101530+0400) and Extended format (YYYY-MM-DDThh:mm:ss±hh:mm e.g. 1985-04-12T10:15:30+04:00).
This came up as I received an error for google about an invalid datetime I was generating for my sitemap. I've been using the following to generate my datetime string:
iex> elem(Date.local |> DateFormat.format("{ISO}"), 1)
"2015-11-08T17:44:10.930+0000"
But on closer examination the timezone offset should be colon-separated to be consistent with the extended format (basic + item separators). According to wikipedia's article on ISO-8601:
Representations can be done in one of two formats – a basic format with a minimal number of separators or an extended format with separators added to enhance human readability.[5] The standard notes that "The basic format should be avoided in plain text."[6] The separator used between date values (year, month, week, and day) is the hyphen, while the colon is used as the separator between time values (hours, minutes, and seconds). For example, the 6th day of the 1st month of the year 2009 may be written as "2009-01-06" in the extended format or simply as "20090106" in the basic format without ambiguity.
https://en.wikipedia.org/wiki/ISO_8601#General_principles
Further:
Either basic or extended formats may be used, but both date and time must use the same format. The date expression may be calendar, week, or ordinal, and must use a complete representation.
https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations
I don't know how you want to proceed as this might break backwards compatibility with people currently using the library, but I do believe this is a bug. A nice improvement beyond this would be an option to pass for generating either the basic or extended format.
I haven't dug too much into the code yet but would be happy to give it a shot and submit a PR w/ tests for this fix if you're interested.
Hi there!
I recently noticed a discrepancy in how Timex formats its ISO-8601 datetime strings. It looks like its a mixture of both the basic and extended formats. Basic format (
YYYYMMDDThhmmss±hhmme.g. 19850412T101530+0400) and Extended format (YYYY-MM-DDThh:mm:ss±hh:mme.g. 1985-04-12T10:15:30+04:00).This came up as I received an error for google about an invalid datetime I was generating for my sitemap. I've been using the following to generate my datetime string:
But on closer examination the timezone offset should be colon-separated to be consistent with the extended format (basic + item separators). According to wikipedia's article on ISO-8601:
Further:
I don't know how you want to proceed as this might break backwards compatibility with people currently using the library, but I do believe this is a bug. A nice improvement beyond this would be an option to pass for generating either the basic or extended format.
I haven't dug too much into the code yet but would be happy to give it a shot and submit a PR w/ tests for this fix if you're interested.