aboutsummaryrefslogtreecommitdiffstats
path: root/time.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-12 02:25:37 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-12 02:25:37 +0000
commit112acd7d42e4f290f0c0fd526f1d3a625dae60b2 (patch)
tree8c9c93b4c201c87e4edcce57e3a6779bf4bb0b03 /time.c
parent93e60c68429c89a3ac8f92f10699458b18bab5ec (diff)
downloadruby-112acd7d42e4f290f0c0fd526f1d3a625dae60b2.tar.gz
Just copy tzmode
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r--time.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/time.c b/time.c
index 5ba13efb9e..dab78ed132 100644
--- a/time.c
+++ b/time.c
@@ -3882,28 +3882,18 @@ time_to_s(VALUE time)
}
static VALUE
-time_add(struct time_object *tobj, VALUE torig, VALUE offset, int sign)
+time_add(const struct time_object *tobj, VALUE torig, VALUE offset, int sign)
{
VALUE result;
+ struct time_object *result_tobj;
+
offset = num_exact(offset);
if (sign < 0)
result = time_new_timew(rb_cTime, wsub(tobj->timew, rb_time_magnify(v2w(offset))));
else
result = time_new_timew(rb_cTime, wadd(tobj->timew, rb_time_magnify(v2w(offset))));
- if (TZMODE_UTC_P(tobj)) {
- GetTimeval(result, tobj);
- TZMODE_SET_UTC(tobj);
- }
- else if (TZMODE_FIXOFF_P(tobj)) {
- VALUE off = tobj->vtm.utc_offset;
- 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;
- }
+ GetTimeval(result, result_tobj);
+ TZMODE_COPY(result_tobj, tobj);
return result;
}