Wrong zone with DateTime parser #16124

Closed
top4ek opened this Issue Jul 10, 2014 · 1 comment

Comments

Projects
None yet
2 participants

top4ek commented Jul 10, 2014

Got wrong behavior with DateTime.parse method:

2.1.2 :001 > DateTime.parse('Wed Apr 30 13:48:37 YEKT 2014')
=> Wed, 30 Apr 2014 13:48:37 +0000

2.1.2 :002 > DateTime.parse('Wed Apr 30 13:48:37 MSK 2014')
=> Wed, 30 Apr 2014 13:48:37 +0300

YEKT is +0600, but we see +0000. Same for VLAT and others I beleive. Parcer just drops zone info from string, but it knows about MSK.

Same with Time.zone.parse:

2.1.2 :010 > Time.zone.parse('Wed Apr 30 13:48:37 YEKT 2014')
=> Wed, 30 Apr 2014 13:48:37 UTC +00:00

2.1.2 :011 > Time.zone.parse('Wed Apr 30 13:48:37 MSK 2014')
=> Wed, 30 Apr 2014 10:48:37 UTC +00:00

2.1.2 :012 > Time.zone.parse('Wed Apr 30 13:48:37 UTC 2014')
=> Wed, 30 Apr 2014 13:48:37 UTC +00:00

Owner

pixeltrix commented Jul 10, 2014

This is a underlying problem with the Ruby date/time parsing code - it only knows a subset of the timezone codes. You can see the list here:

https://github.com/ruby/ruby/blob/trunk/ext/date/date_parse.c#L341-L417

pixeltrix closed this Jul 10, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment