summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-12 02:25:38 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-12 02:25:38 +0000
commit75ac8e866ba16ce5492d02ca7a2146f5905f0bff (patch)
treedea59428d71a99844ad74a974e2fbce2273e30d5
parent093398f979216d95ac9aaf1cef1055195eeca441 (diff)
Load as FIXOFF mode if zone is present
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--test/ruby/test_time_tz.rb1
-rw-r--r--time.c11
2 files changed, 8 insertions, 4 deletions
diff --git a/test/ruby/test_time_tz.rb b/test/ruby/test_time_tz.rb
index 97d8c432e8..d3da269d17 100644
--- a/test/ruby/test_time_tz.rb
+++ b/test/ruby/test_time_tz.rb
@@ -546,6 +546,7 @@ module TestTimeTZ::WithTZ
t2 = Marshal.load(Marshal.dump(t))
assert_equal(t, t2)
assert_equal(t.utc_offset, t2.utc_offset)
+ assert_equal(t.utc_offset, (t2+1).utc_offset)
end
end
diff --git a/time.c b/time.c
index dab78ed132..061ab9e240 100644
--- a/time.c
+++ b/time.c
@@ -1257,7 +1257,9 @@ gmtimew(wideval_t timew, struct vtm *result)
result->wday = tm.tm_wday;
result->yday = tm.tm_yday+1;
result->isdst = tm.tm_isdst;
+#if 0
result->zone = rb_fstring_usascii("UTC");
+#endif
return result;
}
@@ -1716,8 +1718,7 @@ PACKED_STRUCT_UNALIGNED(struct time_object {
#define TZMODE_FIXOFF_P(tobj) ((tobj)->tzmode == TIME_TZMODE_FIXOFF)
#define TZMODE_SET_FIXOFF(tobj, off) \
((tobj)->tzmode = TIME_TZMODE_FIXOFF, \
- (tobj)->vtm.utc_offset = (off), \
- (tobj)->vtm.zone = Qnil)
+ (tobj)->vtm.utc_offset = (off))
#define TZMODE_COPY(tobj1, tobj2) \
((tobj1)->tzmode = (tobj2)->tzmode, \
@@ -1766,6 +1767,7 @@ time_s_alloc(VALUE klass)
tobj->tzmode = TIME_TZMODE_UNINITIALIZED;
tobj->tm_got=0;
tobj->timew = WINT2FIXWV(0);
+ tobj->vtm.zone = Qnil;
return obj;
}
@@ -3728,7 +3730,7 @@ time_fixoff(VALUE time)
{
struct time_object *tobj;
struct vtm vtm;
- VALUE off;
+ VALUE off, zone;
GetTimeval(time, tobj);
if (TZMODE_FIXOFF_P(tobj)) {
@@ -3746,7 +3748,9 @@ time_fixoff(VALUE time)
GMTIMEW(tobj->timew, &vtm);
+ zone = tobj->vtm.zone;
tobj->vtm = vtm;
+ tobj->vtm.zone = zone;
vtm_add_offset(&tobj->vtm, off);
tobj->tm_got = 1;
@@ -4972,7 +4976,6 @@ end_submicro: ;
time_fixoff(time);
}
if (!NIL_P(zone)) {
- if (TZMODE_FIXOFF_P(tobj)) TZMODE_SET_LOCALTIME(tobj);
zone = rb_fstring(zone);
tobj->vtm.zone = zone;
}