diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-09-04 17:21:53 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-09-04 17:21:53 +0000 |
commit | cbe89cef1a8b0f96fc8e39b66f5545f39c869429 (patch) | |
tree | da1ec2434b59abf88e7630e086f8a7e37cef6058 /time.c | |
parent | eff9686dedf3525fe6ec6ea60d7a598893fe3dd3 (diff) | |
download | ruby-cbe89cef1a8b0f96fc8e39b66f5545f39c869429.tar.gz |
* time.c (time_to_s): make it conform to RFC2822 date format.
[ruby-dev:29467]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r-- | time.c | 29 |
1 files changed, 12 insertions, 17 deletions
@@ -1198,32 +1198,27 @@ time_to_s(VALUE time) struct time_object *tobj; char buf[128]; int len; + time_t off; + char buf2[32]; + char sign = '+'; GetTimeval(time, tobj); if (tobj->tm_got == 0) { time_get_tm(time, tobj->gmt); } - if (tobj->gmt == 1) { - len = strftime(buf, 128, "%a %b %d %H:%M:%S UTC %Y", &tobj->tm); - } - else { - time_t off; - char buf2[32]; - char sign = '+'; #if defined(HAVE_STRUCT_TM_TM_GMTOFF) - off = tobj->tm.tm_gmtoff; + off = tobj->tm.tm_gmtoff; #else - VALUE tmp = time_utc_offset(time); - off = NUM2INT(tmp); + VALUE tmp = time_utc_offset(time); + off = NUM2INT(tmp); #endif - if (off < 0) { - sign = '-'; - off = -off; - } - sprintf(buf2, "%%a %%b %%d %%H:%%M:%%S %c%02d%02d %%Y", - sign, (int)(off/3600), (int)(off%3600/60)); - len = strftime(buf, 128, buf2, &tobj->tm); + if (off < 0) { + sign = '-'; + off = -off; } + sprintf(buf2, "%%a, %%b %%d %%Y %%H:%%M:%%S %c%02d%02d", + sign, (int)(off/3600), (int)(off%3600/60)); + len = strftime(buf, 128, buf2, &tobj->tm); return rb_str_new(buf, len); } |