diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-02-03 10:02:57 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-02-03 10:02:57 +0000 |
commit | 01bb9da7acfeb868eeec4fc20061c57d85b26cf8 (patch) | |
tree | 9b0ef258786fb82863ed752fc410405f86ac2068 /time.c | |
parent | de0e5e35ae39a03879d8a954dd6b75654c173cd7 (diff) |
*** empty log message ***
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@63 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r-- | time.c | 21 |
1 files changed, 19 insertions, 2 deletions
@@ -421,6 +421,23 @@ time_asctime(time) if (tobj->tm_got == 0) { time_localtime(time); } + len = strftime(buf, 64, "%c", &(tobj->tm)); + + return str_new(buf, len); +} + +static VALUE +time_to_s(time) + VALUE time; +{ + struct time_object *tobj; + char buf[64]; + int len; + + GetTimeval(time, tobj); + if (tobj->tm_got == 0) { + time_localtime(time); + } #ifndef HAVE_TM_ZONE if (tobj->gmt == 1) { len = strftime(buf, 64, "%a %b %d %H:%M:%S GMT %Y", &(tobj->tm)); @@ -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); |