1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
matz 2006-07-27 00:15:07 +00:00
parent d09827ad50
commit e8ed635174
2 changed files with 22 additions and 2 deletions

View file

@ -1,3 +1,8 @@
Thu Jul 27 09:02:03 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* time.c (time_to_s): generate RFC822 style date string.
[ruby-dev:29143]
Wed Jul 26 22:20:59 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* configure.in: add support for as and ASFLAGS. [ruby-dev:29138]

19
time.c
View file

@ -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);
}