From: matz@... (Yukihiro Matsumoto) Date: 2001-03-28T18:13:48+09:00 Subject: [ruby-talk:13263] RCR#U011 Add a method: Time#set(seconds <,microseconds>) Hi, I implemented this one (patch attached), and came to conclusion that if someone really want this feature, it should be implemented in a subclass probably named "ChangeableTime" or "Time::Changeable". Do you think we need a subclass? For RCR#U011 detail, see http://www.rubygarden.com/ruby?NeedDiscussion matz. --- time.c 2001/03/26 14:29:57 1.37 +++ time.c 2001/03/28 09:12:43 @@ -550,2 +550,21 @@ static VALUE +time_set(argc, argv, time) + int argc; + VALUE *argv; + VALUE time; +{ + struct time_object *tobj; + VALUE sec, usec; + + rb_scan_args(argc, argv, "11", &sec, &usec); + time_modify(time); + GetTimeval(time, tobj); + tobj->tv.tv_sec = (time_t)NUM2LONG(sec); + if (argc == 2) { + tobj->tv.tv_usec = (time_t)NUM2LONG(usec); + } + return time; +} + +static VALUE time_localtime(time) @@ -1097,2 +1116,4 @@ rb_define_method(rb_cTime, "usec", time_usec, 0); + + rb_define_method(rb_cTime, "set", time_set, -1);