ruby-changes:52491
From: nobu <ko1@a...>
Date: Wed, 12 Sep 2018 23:37:57 +0900 (JST)
Subject: [ruby-changes:52491] nobu:r64700 (trunk): time.c split time_utc_or_local
nobu 2018-09-12 23:37:51 +0900 (Wed, 12 Sep 2018) New Revision: 64700 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64700 Log: time.c split time_utc_or_local * time.c (time_utc_or_local): split into time_s_mkutc and time_s_mktime without utc flag. Modified files: trunk/time.c Index: time.c =================================================================== --- time.c (revision 64699) +++ time.c (revision 64700) @@ -2437,7 +2437,8 @@ time_s_now(VALUE klass) https://github.com/ruby/ruby/blob/trunk/time.c#L2437 } static int -get_scale(VALUE unit) { +get_scale(VALUE unit) +{ if (unit == ID2SYM(id_nanosecond) || unit == ID2SYM(id_nsec)) { return 1000000000; } @@ -3075,21 +3076,6 @@ tmcmp(struct tm *a, struct tm *b) https://github.com/ruby/ruby/blob/trunk/time.c#L3076 return 0; } -static VALUE -time_utc_or_local(int argc, VALUE *argv, int utc_p, VALUE klass) -{ - struct vtm vtm; - VALUE time; - - time_arg(argc, argv, &vtm); - if (utc_p) - time = time_new_timew(klass, timegmw(&vtm)); - else - time = time_new_timew(klass, timelocalw(&vtm)); - if (utc_p) return time_gmtime(time); - return time_localtime(time); -} - /* * call-seq: * Time.utc(year) -> time @@ -3125,7 +3111,10 @@ time_utc_or_local(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/time.c#L3111 static VALUE time_s_mkutc(int argc, VALUE *argv, VALUE klass) { - return time_utc_or_local(argc, argv, TRUE, klass); + struct vtm vtm; + + time_arg(argc, argv, &vtm); + return time_gmtime(time_new_timew(klass, timegmw(&vtm))); } /* @@ -3156,7 +3145,10 @@ time_s_mkutc(int argc, VALUE *argv, VALU https://github.com/ruby/ruby/blob/trunk/time.c#L3145 static VALUE time_s_mktime(int argc, VALUE *argv, VALUE klass) { - return time_utc_or_local(argc, argv, FALSE, klass); + struct vtm vtm; + + time_arg(argc, argv, &vtm); + return time_localtime(time_new_timew(klass, timelocalw(&vtm))); } /* -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/