summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-02-03 10:02:57 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-02-03 10:02:57 +0000
commit01bb9da7acfeb868eeec4fc20061c57d85b26cf8 (patch)
tree9b0ef258786fb82863ed752fc410405f86ac2068 /time.c
parentde0e5e35ae39a03879d8a954dd6b75654c173cd7 (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.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/time.c b/time.c
index 7dd2bb6..c16a116 100644
--- a/time.c
+++ b/time.c
@@ -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);