summaryrefslogtreecommitdiff
path: root/lib/time.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-03 15:23:29 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-03 15:23:29 +0000
commitc4f29a657691a70165b937e43e608565da2eca49 (patch)
tree130be1aae3503a2e0b0c3d53c6492ea1315fa947 /lib/time.rb
parent0a76ec34eac00a971617d833d2c42ed68f12f911 (diff)
* lib/time.rb (make_time): Produce fixed-offset time object if
appropriate. (Time.strptime): Use d[:zone] instead of d[:offset]. * lib/rss/rss.rb (Time.w3cdtf): Produce fixed-offset time object if appropriate. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/time.rb')
-rw-r--r--lib/time.rb16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/time.rb b/lib/time.rb
index 8ffd42dcd7..507bf28daf 100644
--- a/lib/time.rb
+++ b/lib/time.rb
@@ -258,7 +258,11 @@ class Time
year, mon, day, hour, min, sec =
apply_offset(year, mon, day, hour, min, sec, off)
t = self.utc(year, mon, day, hour, min, sec, usec)
- t.localtime if !zone_utc?(zone)
+ if zone_utc?(zone)
+ t.utc
+ else
+ t.localtime(off)
+ end
t
else
self.local(year, mon, day, hour, min, sec, usec)
@@ -394,14 +398,18 @@ class Time
raise ArgumentError, "invalid strptime format - `#{format}'" unless d
if seconds = d[:seconds]
t = Time.at(seconds)
+ if zone = d[:zone]
+ if zone_utc?(zone)
+ t.utc
+ elsif offset = zone_offset(zone)
+ t.localtime(offset)
+ end
+ end
else
year = d[:year]
year = yield(year) if year && block_given?
t = make_time(year, d[:mon], d[:mday], d[:hour], d[:min], d[:sec], d[:sec_fraction], d[:zone], now)
end
- if offset = d[:offset]
- t.localtime(offset)
- end
t
end