diff options
author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-03-06 09:36:29 +0000 |
---|---|---|
committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-03-06 09:36:29 +0000 |
commit | ddeae36d8e070dcf546a9a65b3b3bde95b085345 (patch) | |
tree | 8b6d62bc0462918b57e2acd15ac1a2791f608501 | |
parent | 3fe46bdb970ed583ef5105cdc51fc046efb4a1fa (diff) |
* time.c (time_to_s): Back out the format changes; discussed
in [ruby-dev:30495].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | NEWS | 8 | ||||
-rw-r--r-- | time.c | 40 |
3 files changed, 26 insertions, 27 deletions
@@ -1,3 +1,8 @@ +Tue Mar 6 18:24:19 2007 Akinori MUSHA <knu@iDaemons.org> + + * time.c (time_to_s): Back out the format changes; discussed + in [ruby-dev:30495]. + Tue Mar 6 11:53:25 2007 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> * ext/tk/sample/irbtkw.rbw: fails to exit process. @@ -89,14 +89,6 @@ with all sufficient information, see the ChangeLog file. * builtin classes - * Time#to_s now returns a string in a form that - conforms to RFC2822. - - # Before - "Wed Mar 03 12:34:56 JST 2007" - # After - "Wed, 03 Mar 2007 12:34:56 +0900" - * String#intern now raises SecurityError when $SAFE level is greater than zero. @@ -1239,11 +1239,11 @@ time_asctime(time) * time.to_s => string * * Returns a string representing <i>time</i>. Equivalent to calling - * <code>Time#strftime</code> with a format string of ``<code>%a,</code> - * <code>%d</code> <code>%b</code> <code>%H:%M:%S</code> - * <code>%Z</code> <code>%Y</code>'' (the RFC 2822 style). + * <code>Time#strftime</code> with a format string of ``<code>%a</code> + * <code>%b</code> <code>%d</code> <code>%H:%M:%S</code> + * <code>%Z</code> <code>%Y</code>''. * - * Time.now.to_s #=> "Wed 09 Apr 08:56:04 CDT 2003" + * Time.now.to_s #=> "Wed Apr 09 08:56:04 CDT 2003" */ static VALUE @@ -1253,30 +1253,32 @@ time_to_s(time) struct time_object *tobj; char buf[128]; int len; - time_t off; - char buf2[32]; - char sign = '+'; -#if !defined(HAVE_STRUCT_TM_TM_GMTOFF) - VALUE tmp; -#endif 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 - tmp = time_utc_offset(time); - off = NUM2INT(tmp); + VALUE tmp = time_utc_offset(time); + off = NUM2INT(tmp); #endif - if (off < 0) { - sign = '-'; - off = -off; + 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); } - sprintf(buf2, "%%a, %%d %%b %%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); } |