aboutsummaryrefslogtreecommitdiffstats
path: root/time.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-08 04:03:32 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-08 04:03:32 +0000
commita75c56eaf0cfa5b8a016329a2ef1f350ab7de779 (patch)
treecb5a947db7decdc303dda63630b4191741c2884d /time.c
parente5d9e98fdc6a4712d7c5642b5cc9436aab5af676 (diff)
downloadruby-a75c56eaf0cfa5b8a016329a2ef1f350ab7de779.tar.gz
Timezone at Time#+ and Time#-
* time.c (time_add): support for Timezone. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r--time.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/time.c b/time.c
index 0b3056bb7a..5ba13efb9e 100644
--- a/time.c
+++ b/time.c
@@ -3899,6 +3899,11 @@ time_add(struct time_object *tobj, VALUE torig, VALUE offset, int sign)
GetTimeval(result, tobj);
TZMODE_SET_FIXOFF(tobj, off);
}
+ else if (TZMODE_LOCALTIME_P(tobj)) {
+ VALUE zone = tobj->vtm.zone;
+ GetTimeval(result, tobj);
+ tobj->vtm.zone = zone;
+ }
return result;
}
@@ -3982,6 +3987,9 @@ rb_time_succ(VALUE time)
time = time_new_timew(rb_cTime, wadd(tobj->timew, WINT2FIXWV(TIME_SCALE)));
GetTimeval(time, tobj2);
TZMODE_COPY(tobj2, tobj);
+ if (TZMODE_LOCALTIME_P(tobj2) && maybe_tzobj_p(tobj2->vtm.zone)) {
+ zone_localtime(tobj2->vtm.zone, time);
+ }
return time;
}