summaryrefslogtreecommitdiff
path: root/lib/time.rb
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-11-30 09:24:18 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-11-30 09:24:18 +0000
commit9db194227f41b824d15a93e0d2020ec72a5c1c33 (patch)
treeee9bda3efc36853d96fd58debbc0868f0dc8d2b5 /lib/time.rb
parent49d432b6cafbeddcf35981803685cfa690fc0764 (diff)
merges r20365 from trunk into ruby_1_9_1.
* add comment and test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20419 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/time.rb')
-rw-r--r--lib/time.rb34
1 files changed, 32 insertions, 2 deletions
diff --git a/lib/time.rb b/lib/time.rb
index 85c715b80b..3555571f22 100644
--- a/lib/time.rb
+++ b/lib/time.rb
@@ -84,8 +84,26 @@ class Time
end
def zone_utc?(zone)
- # * +0000 means localtime. [RFC 2822]
- # * GMT is a localtime abbreviation in Europe/London, etc.
+ # * +0000
+ # In RFC 2822, +0000 indicate a time zone at Universal Time.
+ # Europe/London is "a time zone at Universal Time" in Winter.
+ # Europe/Lisbon is "a time zone at Universal Time" in Winter.
+ # Atlantic/Reykjavik is "a time zone at Universal Time".
+ # Africa/Dakar is "a time zone at Universal Time".
+ # So +0000 is a local time such as Europe/London, etc.
+ # * GMT
+ # GMT is used as a time zone abbreviation in Europe/London,
+ # Africa/Dakar, etc.
+ # So it is a local time.
+ #
+ # * -0000, -00:00
+ # In RFC 2822, -0000 the date-time contains no information about the
+ # local time zone.
+ # In RFC 3339, -00:00 is used for the time in UTC is known,
+ # but the offset to local time is unknown.
+ # They are not appropriate for specific time zone such as
+ # Europe/London because time zone neutral,
+ # So -00:00 and -0000 are treated as UTC.
if /\A(?:-00:00|-0000|-00|UTC|Z|UT)\z/i =~ zone
true
else
@@ -741,6 +759,18 @@ if __FILE__ == $0
assert_equal(true, Time.rfc2822("Sat, 01 Jan 2000 00:00:00 UTC").utc?)
end
+ def test_rfc2822_utc_roundtrip_winter
+ t1 = Time.local(2008,12,1)
+ t2 = Time.rfc2822(t1.rfc2822)
+ assert_equal(t1.utc?, t2.utc?, "[ruby-dev:37126]")
+ end
+
+ def test_rfc2822_utc_roundtrip_summer
+ t1 = Time.local(2008,8,1)
+ t2 = Time.rfc2822(t1.rfc2822)
+ assert_equal(t1.utc?, t2.utc?)
+ end
+
def test_parse_leap_second
t = Time.utc(1998,12,31,23,59,59)
assert_equal(t, Time.parse("Thu Dec 31 23:59:59 UTC 1998"))