Actions
Bug #14034
closedTime.parse does not handle timezone offsets with seconds
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.5.0dev (2017-10-19 trunk 60215) [x86_64-openbsd]
Backport:
Description
DateTime.parse
handles them correctly, and DateTime.parse.to_time
results in the correct time. Time.parse
doesn't handle them correctly because Time.zone_offset
uses a different regexp that only considers hours and minutes, not seconds.
Example:
DateTime.parse("1200-02-15 BC 14:13:20-00:00:00").to_time
# => -1199-02-15 14:13:20 +0000
Time.parse("1200-02-15 BC 14:13:20-00:00:00")
# => -1199-02-15 14:13:20 -0752
Time.parse("1200-02-15 BC 14:13:20-00:00")
# => -1199-02-15 14:13:20 UTC
The attached patch fixes the issue by having the Time.zone_offset
regexp respect seconds if they are present.
Files
Actions
Like0
Like0