Bug #14034
closedTime.parse does not handle timezone offsets with seconds
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
Updated by nobu (Nobuyoshi Nakada) almost 7 years ago
- Status changed from Open to Closed
Applied in changeset trunk|r60216.
Make Time.parse respect timezone offset seconds
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.
[ruby-core:83400] [Bug #14034]
From: Jeremy Evans code@jeremyevans.net