Project

General

Profile

Actions

Bug #16286

closed

DateTime.parse timezone errors

Added by matt17r (Matthew LS) over 4 years ago. Updated over 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]
[ruby-core:95597]

Description

Trying to parse a DateTime using Australian time zone abbreviations doesn't work:

>> DateTime.parse('2019-10-31 10:49:52.36400 AEST')
=> #<DateTime: 2019-10-31T10:49:52+00:00 ((2458788j,38992s,364000000n),+0s,2299161j)>
# offset is +00:00 not +10:00     ^^^^^^

As per this comment on a Rails issue, timezones are listed in ext/date/zonetab.list. Should these abbreviations be correct or are they deprecated?

Steps to reproduce:

>> require 'date'
=> true
>> DateTime.parse('2019-10-31 10:49:52.36400 AEST').zone
=> +00:00 # expected +10:00
>> DateTime.parse('2019-10-31 10:49:52.36400 AEDT').zone
=> +00:00 # expected +11:00
>> DateTime.parse('2019-10-31 10:49:52.36400 EAST').zone
=> +10:00 # expected -06:00
>> DateTime.parse('2019-10-31 10:49:52.36400 EASST').zone
=> +00:00 # expected -05:00

Additional info:
ext/date/zonetab.list lists "EAST" with an offset of +10. EAST is the abbreviation for Easter Island, not for Australia Eastern Standard Time.

References:

  1. the most recent data from IANA (2019c at time of writing) refers to the timezones as AEST (or AEDT for DST)
  2. the Australian government uses AEST (or AEDT for DST)
  3. EAST isn't referenced by IANA but there are several sources that use EAST for Easter Island, off the coast of Chile (-6 rather than +10).

Files

DateTime_parse_AEST_timezone_issue.rb (479 Bytes) DateTime_parse_AEST_timezone_issue.rb matt17r (Matthew LS), 10/31/2019 12:46 AM

Updated by shyouhei (Shyouhei Urabe) over 4 years ago

Curious where were those abbreviation from. According to git log -G, It was introduced in this commit https://github.com/ruby/ruby/commit/dc9cd6a8c22ad04baa7498fd0cbc5d519ed73be0 but no description came with it.

Maybe it's better to follow authoritative information such as tzdata.

Updated by jeremyevans0 (Jeremy Evans) over 4 years ago

shyouhei (Shyouhei Urabe) wrote:

Curious where were those abbreviation from. According to git log -G, It was introduced in this commit https://github.com/ruby/ruby/commit/dc9cd6a8c22ad04baa7498fd0cbc5d519ed73be0 but no description came with it.

Maybe it's better to follow authoritative information such as tzdata.

I agree. Not having much experience with the tz database, I'm not sure how to easily get abbreviation info out of it. The tzinfo gem doesn't appear to expose a list of all abbreviations, though recent versions do allow getting current abbreviations for particular timezones. It is hard to use that feature to add missing timezones, though.

I did find an alternative source for timezone abbreviations that was easier to deal with: https://www.timeanddate.com/time/zones/. Not sure how authoritative it is, but it seems reasonable. It does include AEST, AEDT, and EASST. For backwards compatibility, we shouldn't change EAST. I've submitted a pull request to add new unambiguous time zones listed on that site: https://github.com/ruby/date/pull/16

Actions #3

Updated by jeremyevans0 (Jeremy Evans) over 4 years ago

  • Status changed from Open to Closed
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0