зеркало из https://github.com/github/ruby.git
* 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
This commit is contained in:
Родитель
585c61691e
Коммит
ddfc925c8d
|
@ -3,6 +3,11 @@ Thu Sep 7 23:27:05 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
* file.c (path_check_0, fpath_check): disable path check on cygwin.
|
* file.c (path_check_0, fpath_check): disable path check on cygwin.
|
||||||
[ruby-talk:213074]
|
[ruby-talk:213074]
|
||||||
|
|
||||||
|
Thu Sep 7 02:03:45 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* time.c (time_to_s): adopt new date format using digits
|
||||||
|
e.g. "2006-09-07 02:03:45 +9000".
|
||||||
|
|
||||||
Thu Sep 7 01:54:22 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Thu Sep 7 01:54:22 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* string.c (sym_equal): override. check equivalence.
|
* string.c (sym_equal): override. check equivalence.
|
||||||
|
|
38
time.c
38
time.c
|
@ -1198,30 +1198,32 @@ time_to_s(VALUE time)
|
||||||
struct time_object *tobj;
|
struct time_object *tobj;
|
||||||
char buf[128];
|
char buf[128];
|
||||||
int len;
|
int len;
|
||||||
time_t off;
|
|
||||||
char buf2[32];
|
|
||||||
char sign = '+';
|
|
||||||
#if !defined(HAVE_STRUCT_TM_TM_GMTOFF)
|
|
||||||
VALUE tmp;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
GetTimeval(time, tobj);
|
GetTimeval(time, tobj);
|
||||||
if (tobj->tm_got == 0) {
|
if (tobj->tm_got == 0) {
|
||||||
time_get_tm(time, tobj->gmt);
|
time_get_tm(time, tobj->gmt);
|
||||||
}
|
}
|
||||||
#if defined(HAVE_STRUCT_TM_TM_GMTOFF)
|
if (tobj->gmt == 1) {
|
||||||
off = tobj->tm.tm_gmtoff;
|
len = strftime(buf, 128, "%Y-%m-%d %H:%M:%S UTC", &tobj->tm);
|
||||||
#else
|
}
|
||||||
tmp = time_utc_offset(time);
|
else {
|
||||||
off = NUM2INT(tmp);
|
time_t off;
|
||||||
#endif
|
char buf2[32];
|
||||||
if (off < 0) {
|
char sign = '+';
|
||||||
sign = '-';
|
#if defined(HAVE_STRUCT_TM_TM_GMTOFF)
|
||||||
off = -off;
|
off = tobj->tm.tm_gmtoff;
|
||||||
|
#else
|
||||||
|
VALUE tmp = time_utc_offset(time);
|
||||||
|
off = NUM2INT(tmp);
|
||||||
|
#endif
|
||||||
|
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);
|
return rb_str_new(buf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче