summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-11 12:09:47 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-11 12:09:47 +0000
commit189ecfd2eb80b2175a1b5201107bb13996b5adb5 (patch)
tree87137a77dc7c3e83070abf054c08b09c151c7b47
parent848e6cfe7ae0008864b2c56fb9c4b83917ed9911 (diff)
extern rb_time_utc_offset to get utc offset
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61116 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--include/ruby/intern.h1
-rw-r--r--time.c15
2 files changed, 8 insertions, 8 deletions
diff --git a/include/ruby/intern.h b/include/ruby/intern.h
index d77e5ec95e..5684b3230a 100644
--- a/include/ruby/intern.h
+++ b/include/ruby/intern.h
@@ -892,6 +892,7 @@ VALUE rb_time_num_new(VALUE, VALUE);
struct timeval rb_time_interval(VALUE num);
struct timeval rb_time_timeval(VALUE time);
struct timespec rb_time_timespec(VALUE time);
+VALUE rb_time_utc_offset(VALUE time);
/* variable.c */
VALUE rb_mod_name(VALUE);
VALUE rb_class_path(VALUE);
diff --git a/time.c b/time.c
index 7a43e58875..e0a95097bd 100644
--- a/time.c
+++ b/time.c
@@ -622,7 +622,6 @@ wv2timet(wideval_t w)
#define WV2TIMET(t) wv2timet(t)
VALUE rb_cTime;
-static VALUE time_utc_offset _((VALUE));
static int obj2int(VALUE obj);
static uint32_t obj2ubits(VALUE obj, size_t bits);
@@ -4192,18 +4191,18 @@ time_zone(VALUE time)
* l.gmt_offset #=> -21600
*/
-static VALUE
-time_utc_offset(VALUE time)
+VALUE
+rb_time_utc_offset(VALUE time)
{
struct time_object *tobj;
GetTimeval(time, tobj);
- MAKE_TM(time, tobj);
if (TIME_UTC_P(tobj)) {
return INT2FIX(0);
}
else {
+ MAKE_TM(time, tobj);
return tobj->vtm.utc_offset;
}
}
@@ -4584,7 +4583,7 @@ time_mdump(VALUE time)
rb_ivar_set(str, id_submicro, rb_str_new(buf, len));
}
if (!TIME_UTC_P(tobj)) {
- VALUE off = time_utc_offset(time), div, mod;
+ VALUE off = rb_time_utc_offset(time), div, mod;
divmodv(off, INT2FIX(1), &div, &mod);
if (rb_equal(mod, INT2FIX(0)))
off = rb_Integer(div);
@@ -4901,9 +4900,9 @@ Init_Time(void)
rb_define_method(rb_cTime, "isdst", time_isdst, 0);
rb_define_method(rb_cTime, "dst?", time_isdst, 0);
rb_define_method(rb_cTime, "zone", time_zone, 0);
- rb_define_method(rb_cTime, "gmtoff", time_utc_offset, 0);
- rb_define_method(rb_cTime, "gmt_offset", time_utc_offset, 0);
- rb_define_method(rb_cTime, "utc_offset", time_utc_offset, 0);
+ rb_define_method(rb_cTime, "gmtoff", rb_time_utc_offset, 0);
+ rb_define_method(rb_cTime, "gmt_offset", rb_time_utc_offset, 0);
+ rb_define_method(rb_cTime, "utc_offset", rb_time_utc_offset, 0);
rb_define_method(rb_cTime, "utc?", time_utc_p, 0);
rb_define_method(rb_cTime, "gmt?", time_utc_p, 0);