summaryrefslogtreecommitdiff
path: root/lib/time.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-20 01:03:18 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-20 01:03:18 +0000
commit90048176ccde574cb315437faecf468f45370dfd ()
tree07b8b3c2e4236429e5ac1764211db8454420599c /lib/time.rb
parentf16f0441d681dd9d2e09631fd068268a63fe1f3b (diff)
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 <[email protected]> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--lib/time.rb4
1 files changed, 2 insertions, 2 deletions
@@ -134,8 +134,8 @@ class Time
def zone_offset(zone, year=self.now.year)
off = nil
zone = zone.upcase
- if /\A([+-])(\d\d):?(\d\d)\z/ =~ zone
- off = ($1 == '-' ? -1 : 1) * ($2.to_i * 60 + $3.to_i) * 60
elsif /\A[+-]\d\d\z/ =~ zone
off = zone.to_i * 3600
elsif ZoneOffset.include?(zone)