Supporting all ISO8601 timezone formats

According to the Wikipedia entry on the ISO8601 spec (https://en.wikipedia.org/wiki/ISO_8601#Time_zone_designators), there are multiple valid ways to represent timezone offsets but the two I’m specifically interested in are:

  • +HHMM
  • +HH:MM

If I run the following query:
SELECT
DATE_FORMAT_STR(‘2016-05-15T00:00:23+00:00’, ‘1111-11-11’) as hours_minutes_delimited_tz,
DATE_FORMAT_STR(‘2016-05-15T00:00:23+0000’, ‘1111-11-11’) as hours_minutes_tz,
DATE_FORMAT_STR(‘2016-05-15T00:00:23+00’, ‘1111-11-11’) as hours_only_tz

I get the following results:
[
{
“hours_minutes_delimited_tz”: “2016-05-15”,
“hours_minutes_tz”: null,
“hours_only_tz”: null
}
]

Curious as to what happens in a browser I wrote this JSFiddle (https://jsfiddle.net/cziclix/2k8o6eys/4/) which parses both formats Chrome or Firefox but delivers an “Invalid Date” error in Safari.

The Couchbase docs on date functions link to this W3C note however that is just a note and not the actual standard. (I am unable to place more than two links as a new user to reference the Couchbase docs or W3C notes directly but can be found in the Developers > N1QL Reference > Functions > Date Functions section.

I do not have access to the actual ISO8601 doc (ironically, the reason the W3C note was even created) but it seems like it would be most correct to allow parsing of all the allowable TZ formats.

You can track the issue MB-28623