#1556 Timezone support (ISO 8601) - doesn't support all formats

tcolar Fri 10 Jun 2011

ToLocale says that "z" should support ISO8601 Timezones http://fantom.org/doc/sys/DateTime.html#toLocale

However 8601 says timezone can be written'+05:00' (that works) but also +05 or +0500 (neither works)

dt := DateTime.fromLocale("10JUN201112:19-03:30", "DMMMYYYYhh:mmz", TimeZone.cur, false)

// works
verifyEq(dt, DateTime.fromIso("2011-06-10T12:19:00-03:30"))

// fails
dt = DateTime.fromLocale("10JUN201112:19-0330", "DMMMYYYYhh:mmz", TimeZone.cur, false)
verifyEq(dt, DateTime.fromIso("2011-06-10T12:19:00-03:30"))

// sys::TestErr: Test failed: 2011-06-10T12:19:00-03:00 GMT+3 [sys::DateTime] != 2011-06-10T12:19:00-03:00 GMT+3 [sys::DateTime]

brian Fri 10 Jun 2011

Promoted to ticket #1556 and assigned to brian

I haven't personally ever seen that format used. But easy to add, I will take a look.

tcolar Fri 10 Jun 2011

Used in Mail messages:

RFC 5322 3.3

zone            =   (FWS ( "+" / "-" ) 4DIGIT) 

brian Mon 14 Nov 2011

Ticket resolved in 1.0.61

This actually mostly just worked already if the tz offset was at the end of the string since the minutes just got ignored. But I did change the behavior so that the "hh:mm", "hhmm" and "hh" are all supported (even if not at end of string).

Although your example code is really a different problem: how to handle a tz offset that is a fractional hour. Without further context we don't really know what timezone to use and we can't just fallback to one of the generic GMT+/- timezones because the tzinfo database doesn't define any fractional hour timezones like GMT-3:30. I just left the current behavior to pick one of the standard generic timezones - so if your offset is is -3:30, then you will get GMT+3 as the actual TimeZone instance. That seems a lesser evil than using timezone names which aren't standardized by tzinfo database. Just another reason that politicians that define fractional UTC offsets are just plain evil.

Login or Signup to reply.