From fcf308e5fc6e0015a89ac57f6d40fec4bc3d99db Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 8 Oct 2018 04:03:32 +0000 Subject: 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 --- time.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'time.c') 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; } -- cgit v1.2.3