time.c: optional arguments of Time::TM#initialize
* time.c (tm_initialize): arguments other than year are optional now as Time.new. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65296 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3dc960deab
commit
8747974d4b
@ -488,7 +488,7 @@ End
|
|||||||
end
|
end
|
||||||
|
|
||||||
def add_offset(t, ofs)
|
def add_offset(t, ofs)
|
||||||
Time::TM.new(*Time.send(:apply_offset, *t.to_a[0, 6].reverse, ofs))
|
Time.utc(*Time.send(:apply_offset, *t.to_a[0, 6].reverse, ofs))
|
||||||
rescue => e
|
rescue => e
|
||||||
raise e.class, sprintf("%s: %p %+d", e.message, t, ofs)
|
raise e.class, sprintf("%s: %p %+d", e.message, t, ofs)
|
||||||
end
|
end
|
||||||
|
10
time.c
10
time.c
@ -5014,7 +5014,7 @@ tm_from_time(VALUE klass, VALUE time)
|
|||||||
{
|
{
|
||||||
struct time_object *tobj;
|
struct time_object *tobj;
|
||||||
struct vtm vtm, *v;
|
struct vtm vtm, *v;
|
||||||
#ifdef TM_IS_TIME
|
#if TM_IS_TIME
|
||||||
VALUE tm;
|
VALUE tm;
|
||||||
struct time_object *ttm;
|
struct time_object *ttm;
|
||||||
|
|
||||||
@ -5065,11 +5065,11 @@ tm_from_time(VALUE klass, VALUE time)
|
|||||||
static VALUE
|
static VALUE
|
||||||
tm_initialize(int argc, VALUE *argv, VALUE tm)
|
tm_initialize(int argc, VALUE *argv, VALUE tm)
|
||||||
{
|
{
|
||||||
#ifdef TM_IS_TIME
|
#if TM_IS_TIME
|
||||||
struct time_object *tobj = DATA_PTR(tm);
|
struct time_object *tobj = DATA_PTR(tm);
|
||||||
struct vtm vtm;
|
struct vtm vtm;
|
||||||
|
|
||||||
rb_check_arity(argc, 6, 6);
|
rb_check_arity(argc, 1, 6);
|
||||||
time_arg(argc, argv, &vtm);
|
time_arg(argc, argv, &vtm);
|
||||||
tobj->tzmode = TIME_TZMODE_UTC;
|
tobj->tzmode = TIME_TZMODE_UTC;
|
||||||
tobj->timew = timegmw(&vtm);
|
tobj->timew = timegmw(&vtm);
|
||||||
@ -5109,7 +5109,7 @@ tm_initialize(int argc, VALUE *argv, VALUE tm)
|
|||||||
static VALUE
|
static VALUE
|
||||||
tm_to_time(VALUE tm)
|
tm_to_time(VALUE tm)
|
||||||
{
|
{
|
||||||
#ifdef TM_IS_TIME
|
#if TM_IS_TIME
|
||||||
struct time_object *torig = get_timeval(tm);
|
struct time_object *torig = get_timeval(tm);
|
||||||
VALUE dup = time_s_alloc(rb_cTime);
|
VALUE dup = time_s_alloc(rb_cTime);
|
||||||
struct time_object *tobj = DATA_PTR(dup);
|
struct time_object *tobj = DATA_PTR(dup);
|
||||||
@ -5279,7 +5279,7 @@ Init_Time(void)
|
|||||||
rb_cTime = rb_define_class("Time", rb_cObject);
|
rb_cTime = rb_define_class("Time", rb_cObject);
|
||||||
rb_include_module(rb_cTime, rb_mComparable);
|
rb_include_module(rb_cTime, rb_mComparable);
|
||||||
|
|
||||||
#ifdef TM_IS_TIME
|
#if TM_IS_TIME
|
||||||
rb_cTimeTM = rb_define_class_under(rb_cTime, "TM", rb_cTime);
|
rb_cTimeTM = rb_define_class_under(rb_cTime, "TM", rb_cTime);
|
||||||
#else
|
#else
|
||||||
rb_cTimeTM = rb_struct_define_under(rb_cTime, "TM",
|
rb_cTimeTM = rb_struct_define_under(rb_cTime, "TM",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user