зеркало из https://github.com/github/ruby.git
* time.c (make_time_t): try search_time_t if mktime/timegm is failed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3599 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
e689d077e3
Коммит
8f8a31b0e9
|
@ -1,7 +1,11 @@
|
|||
Sat Mar 22 15:50:29 2003 Tanaka Akira <akr@m17n.org>
|
||||
|
||||
* time.c (make_time_t): try search_time_t if mktime/timegm is failed.
|
||||
|
||||
Sat Mar 22 13:26:33 2003 Tanaka Akira <akr@m17n.org>
|
||||
|
||||
* lib/optparse.rb, lib/jcode.rb, ext/tk/lib/tk.rb: reorder character
|
||||
class /[\]\[]/ to /[\[\]]/ to readability.
|
||||
class /[\]\[]/ to /[\[\]]/ for readability.
|
||||
|
||||
Sat Mar 22 12:44:15 2003 Tanaka Akira <akr@m17n.org>
|
||||
|
||||
|
|
57
time.c
57
time.c
|
@ -336,7 +336,6 @@ static VALUE time_gmtime _((VALUE));
|
|||
static VALUE time_localtime _((VALUE));
|
||||
static VALUE time_get_tm _((VALUE, int));
|
||||
|
||||
#if !defined HAVE_TIMEGM
|
||||
static int
|
||||
tmcmp(a, b)
|
||||
struct tm *a;
|
||||
|
@ -587,7 +586,6 @@ search_time_t(tptr, utc_p)
|
|||
rb_raise(rb_eArgError, "gmtime/localtime error");
|
||||
return 0; /* not reached */
|
||||
}
|
||||
#endif
|
||||
|
||||
static time_t
|
||||
make_time_t(tptr, utc_p)
|
||||
|
@ -599,43 +597,38 @@ make_time_t(tptr, utc_p)
|
|||
buf = *tptr;
|
||||
if (utc_p) {
|
||||
#if defined(HAVE_TIMEGM)
|
||||
t = timegm(&buf);
|
||||
if (t == -1) {
|
||||
if ((t = timegm(&buf)) != -1)
|
||||
return t;
|
||||
#ifdef NEGATIVE_TIME_T
|
||||
if (!(tmp = gmtime(&t)) ||
|
||||
tptr->tm_year != tmp->tm_year ||
|
||||
tptr->tm_mon != tmp->tm_mon ||
|
||||
tptr->tm_mday != tmp->tm_mday ||
|
||||
tptr->tm_hour != tmp->tm_hour ||
|
||||
tptr->tm_min != tmp->tm_min ||
|
||||
tptr->tm_sec != tmp->tm_sec)
|
||||
if ((tmp = gmtime(&t)) &&
|
||||
tptr->tm_year == tmp->tm_year &&
|
||||
tptr->tm_mon == tmp->tm_mon &&
|
||||
tptr->tm_mday == tmp->tm_mday &&
|
||||
tptr->tm_hour == tmp->tm_hour &&
|
||||
tptr->tm_min == tmp->tm_min &&
|
||||
tptr->tm_sec == tmp->tm_sec)
|
||||
return t;
|
||||
#endif
|
||||
rb_raise(rb_eArgError, "gmtime error");
|
||||
}
|
||||
#else
|
||||
t = search_time_t(&buf, utc_p);
|
||||
#endif
|
||||
return search_time_t(&buf, utc_p);
|
||||
}
|
||||
else {
|
||||
#if defined(HAVE_MKTIME)
|
||||
t = mktime(&buf);
|
||||
if (t == -1) {
|
||||
#ifdef NEGATIVE_TIME_T
|
||||
if (!(tmp = localtime(&t)) ||
|
||||
tptr->tm_year != tmp->tm_year ||
|
||||
tptr->tm_mon != tmp->tm_mon ||
|
||||
tptr->tm_mday != tmp->tm_mday ||
|
||||
tptr->tm_hour != tmp->tm_hour ||
|
||||
tptr->tm_min != tmp->tm_min ||
|
||||
tptr->tm_sec != tmp->tm_sec)
|
||||
#endif
|
||||
rb_raise(rb_eArgError, "localtime error");
|
||||
}
|
||||
#else
|
||||
t = search_time_t(&buf, utc_p);
|
||||
#endif
|
||||
}
|
||||
if ((t = mktime(&buf)) != -1)
|
||||
return t;
|
||||
#ifdef NEGATIVE_TIME_T
|
||||
if ((tmp = localtime(&t)) &&
|
||||
tptr->tm_year == tmp->tm_year &&
|
||||
tptr->tm_mon == tmp->tm_mon &&
|
||||
tptr->tm_mday == tmp->tm_mday &&
|
||||
tptr->tm_hour == tmp->tm_hour &&
|
||||
tptr->tm_min == tmp->tm_min &&
|
||||
tptr->tm_sec == tmp->tm_sec)
|
||||
return t;
|
||||
#endif
|
||||
#endif
|
||||
return search_time_t(&buf, utc_p);
|
||||
}
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
|
Загрузка…
Ссылка в новой задаче