diff options
author | (no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-02-10 08:44:05 +0000 |
---|---|---|
committer | (no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-02-10 08:44:05 +0000 |
commit | 36f3603cae6536e571220721e916b8d284cf0675 (patch) | |
tree | eb9605811483000f6980263aa163b4f627ab1c3f /time.c | |
parent | fd1d8cdc09ed86e4a0812120a17ff0d7b04adcaf (diff) |
This commit was manufactured by cvs2svn to create tag 'v1_1b7'.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_1b7@70 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r-- | time.c | 25 |
1 files changed, 21 insertions, 4 deletions
@@ -6,7 +6,7 @@ $Date$ created at: Tue Dec 28 14:31:59 JST 1993 - Copyright (C) 1993-1996 Yukihiro Matsumoto + Copyright (C) 1993-1998 Yukihiro Matsumoto ************************************************/ @@ -201,7 +201,7 @@ time_arg(argc, argv, args) } /* value validation */ - if ( args[0] < 70|| args[1] > 137 + if ( args[0] < 70|| args[0] > 137 || args[1] < 0 || args[1] > 11 || args[2] < 1 || args[2] > 31 || args[3] < 0 || args[3] > 23 @@ -414,6 +414,23 @@ time_asctime(time) VALUE time; { struct time_object *tobj; + char *s; + + GetTimeval(time, tobj); + if (tobj->tm_got == 0) { + time_localtime(time); + } + s = asctime(&(tobj->tm)); + if (s[24] == '\n') s[24] = '\0'; + + return str_new2(s); +} + +static VALUE +time_to_s(time) + VALUE time; +{ + struct time_object *tobj; char buf[64]; int len; @@ -774,8 +791,8 @@ Init_Time() rb_define_method(cTime, "gmtime", time_gmtime, 0); rb_define_method(cTime, "ctime", time_asctime, 0); rb_define_method(cTime, "asctime", time_asctime, 0); - rb_define_method(cTime, "to_s", time_asctime, 0); - rb_define_method(cTime, "inspect", time_asctime, 0); + rb_define_method(cTime, "to_s", time_to_s, 0); + rb_define_method(cTime, "inspect", time_to_s, 0); rb_define_method(cTime, "to_a", time_to_a, 0); rb_define_method(cTime, "+", time_plus, 1); |