ruby-changes:48997
From: naruse <ko1@a...>
Date: Mon, 11 Dec 2017 21:09:52 +0900 (JST)
Subject: [ruby-changes:48997] naruse:r61116 (trunk): extern rb_time_utc_offset to get utc offset
naruse 2017-12-11 21:09:47 +0900 (Mon, 11 Dec 2017) New Revision: 61116 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61116 Log: extern rb_time_utc_offset to get utc offset Modified files: trunk/include/ruby/intern.h trunk/time.c Index: time.c =================================================================== --- time.c (revision 61115) +++ time.c (revision 61116) @@ -622,7 +622,6 @@ wv2timet(wideval_t w) https://github.com/ruby/ruby/blob/trunk/time.c#L622 #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) https://github.com/ruby/ruby/blob/trunk/time.c#L4191 * 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) https://github.com/ruby/ruby/blob/trunk/time.c#L4583 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) https://github.com/ruby/ruby/blob/trunk/time.c#L4900 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); Index: include/ruby/intern.h =================================================================== --- include/ruby/intern.h (revision 61115) +++ include/ruby/intern.h (revision 61116) @@ -892,6 +892,7 @@ VALUE rb_time_num_new(VALUE, VALUE); https://github.com/ruby/ruby/blob/trunk/include/ruby/intern.h#L892 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); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/