diff options
Diffstat (limited to 'lib/time.rb')
| -rw-r--r-- | lib/time.rb | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/time.rb b/lib/time.rb index a0fc7dfbf5..e6aab3fa5d 100644 --- a/lib/time.rb +++ b/lib/time.rb @@ -27,7 +27,7 @@ require 'date' # # class Time - VERSION = "0.4.1" # :nodoc: + VERSION = "0.4.2" # :nodoc: class << Time @@ -80,7 +80,7 @@ class Time # # You must require 'time' to use this method. # - def zone_offset(zone, year=self.now.year) + def zone_offset(zone, year=nil) off = nil zone = zone.upcase if /\A([+-])(\d\d)(:?)(\d\d)(?:\3(\d\d))?\z/ =~ zone @@ -89,10 +89,13 @@ class Time off = zone.to_i * 3600 elsif ZoneOffset.include?(zone) off = ZoneOffset[zone] * 3600 - elsif ((t = self.local(year, 1, 1)).zone.upcase == zone rescue false) - off = t.utc_offset - elsif ((t = self.local(year, 7, 1)).zone.upcase == zone rescue false) - off = t.utc_offset + else + year ||= self.now.year + if ((t = self.local(year, 1, 1)).zone.upcase == zone rescue false) + off = t.utc_offset + elsif ((t = self.local(year, 7, 1)).zone.upcase == zone rescue false) + off = t.utc_offset + end end off end |
