summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-07-27 00:15:07 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-07-27 00:15:07 +0000
commite8ed635174402f9f99bde387bd1daa25c0310447 (patch)
treed0ab4697afcbc2812cf5ef0eaeb5ab53ce5048a4 /time.c
parentd09827ad50b9da30c33ea124a20aa4999b783c90 (diff)
* time.c (time_to_s): generate RFC822 style date string.
[ruby-dev:29143] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10617 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r--time.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/time.c b/time.c
index 62be1f521c..d68c1dfee3 100644
--- a/time.c
+++ b/time.c
@@ -1203,10 +1203,25 @@ time_to_s(VALUE time)
time_get_tm(time, tobj->gmt);
}
if (tobj->gmt == 1) {
- len = strftime(buf, 128, "%a %b %d %H:%M:%S UTC %Y", &tobj->tm);
+ len = strftime(buf, 128, "%a %b %d %Y %H:%M:%S UTC", &tobj->tm);
}
else {
- len = strftime(buf, 128, "%a %b %d %H:%M:%S %Z %Y", &tobj->tm);
+ time_t off;
+ char buf2[32];
+ char sign = '+';
+#if defined(HAVE_STRUCT_TM_TM_GMTOFF)
+ off = tobj->tm.tm_gmtoff;
+#else
+ VALUE tmp = time_utc_offset(time);
+ off = NUM2INT(tmp);
+#endif
+ if (off < 0) {
+ sign = '-';
+ off = -off;
+ }
+ sprintf(buf2, "%%a %%b %%d %%Y %%H:%%M:%%S %c%02d%02d",
+ sign, off/3600, off%3600/60);
+ len = strftime(buf, 128, buf2, &tobj->tm);
}
return rb_str_new(buf, len);
}