summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-09-07 16:10:33 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-09-07 16:10:33 +0000
commitddfc925c8dd3e864d915f1b1cc67b0bfe0d581d9 (patch)
tree756b292a611e764632f8087ac88799760347c3f3 /time.c
parent585c61691e9877bae84bb71acf0e2f3d1377ce52 (diff)
* time.c (time_to_s): adopt new date format using digits
e.g. "2006-09-07 02:03:45 +9000". git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r--time.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/time.c b/time.c
index cb2ee465c4..c9be587c47 100644
--- a/time.c
+++ b/time.c
@@ -1198,30 +1198,32 @@ time_to_s(VALUE 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, "%Y-%m-%d %H:%M:%S UTC", &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, "%%Y-%%m-%%d %%H:%%M:%%S %c%02d%02d",
+ sign, (int)(off/3600), (int)(off%3600/60));
+ len = strftime(buf, 128, buf2, &tobj->tm);
}
- 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);
}