diff --git test/test_time.rb test/test_time.rb index 0a6659f..167fbbf 100644 --- test/test_time.rb +++ test/test_time.rb @@ -324,6 +324,11 @@ def test_zone_0000 assert_equal(true, Time.rfc2822("Sat, 01 Jan 2000 00:00:00 -0000").utc?) assert_equal(false, Time.rfc2822("Sat, 01 Jan 2000 00:00:00 +0000").utc?) assert_equal(true, Time.rfc2822("Sat, 01 Jan 2000 00:00:00 UTC").utc?) + ENV['TZ'] = 'UTC' + assert_equal(true, Time.now.utc?) + ENV['TZ'] = 'Asia/Tokyo' + assert_equal(false, Time.now.utc?) + ENV['TZ'] = nil end def test_rfc2822_utc_roundtrip_winter diff --git time.c time.c index 603fe8b..85cd943 100644 --- time.c +++ time.c @@ -1925,6 +1925,11 @@ time_init_0(VALUE time) rb_timespec_now(&ts); tobj->timew = timespec2timew(&ts); + MAKE_TM(time, tobj); + if (rb_equal(tobj->vtm.utc_offset, INT2FIX(0))) { + tobj->gmt = 1; + } + return time; }