13 #include <sys/types.h>
30 #if defined(HAVE_SYS_TIME_H)
39 #define NDIV(x,y) (-(-((x)+1)/(y))-1)
40 #define NMOD(x,y) ((y)-(-((x)+1)%(y))-1)
41 #define DIV(n,d) ((n)<0 ? NDIV((n),(d)) : (n)/(d))
42 #define MOD(n,d) ((n)<0 ? NMOD((n),(d)) : (n)%(d))
57 if ((
long)x < (
long)y)
59 if ((
long)x > (
long)y)
66 #define ne(x,y) (!eq((x),(y)))
67 #define lt(x,y) (cmp((x),(y)) < 0)
68 #define gt(x,y) (cmp((x),(y)) > 0)
69 #define le(x,y) (cmp((x),(y)) <= 0)
70 #define ge(x,y) (cmp((x),(y)) >= 0)
96 #if !(HAVE_LONG_LONG && SIZEOF_LONG * 2 <= SIZEOF_LONG_LONG)
100 unsigned long a,
b,
c;
102 if (x == 0 || y == 0) {
108 a = (
unsigned long)-x;
112 a = (
unsigned long)x;
116 b = (
unsigned long)-y;
119 b = (
unsigned long)y;
121 if (a <= ULONG_MAX / b) {
124 if (c <= (
unsigned long)
LONG_MAX + 1) {
144 #if HAVE_LONG_LONG && SIZEOF_LONG * 2 <= SIZEOF_LONG_LONG
160 #define div(x,y) (rb_funcall((x), id_div, 1, (y)))
171 #define neg(x) (sub(INT2FIX(0), (x)))
172 #define lshift(x,y) (rb_funcall((x), id_lshift, 1, (y)))
196 #define mulquo(x,y,z) (((y) == (z)) ? (x) : quo(mul((x),(y)),(z)))
213 # define INT64toNUM(x) LONG2NUM(x)
214 # define UINT64toNUM(x) ULONG2NUM(x)
215 #elif defined(HAVE_LONG_LONG) && SIZEOF_LONG_LONG == 8
216 # define INT64toNUM(x) LL2NUM(x)
217 # define UINT64toNUM(x) ULL2NUM(x)
220 #if defined(HAVE_UINT64_T) && SIZEOF_LONG*2 <= SIZEOF_UINT64_T
225 # define WIDEVALUE_IS_WIDER 1
226 # define UWIDEINT_MAX UINT64_MAX
227 # define WIDEINT_MAX INT64_MAX
228 # define WIDEINT_MIN INT64_MIN
229 # define FIXWINT_P(tv) ((tv) & 1)
230 # define FIXWVtoINT64(tv) RSHIFT((SIGNED_WIDEVALUE)(tv), 1)
231 # define INT64toFIXWV(wi) ((WIDEVALUE)((SIGNED_WIDEVALUE)(wi) << 1 | FIXNUM_FLAG))
232 # define FIXWV_MAX (((int64_t)1 << 62) - 1)
233 # define FIXWV_MIN (-((int64_t)1 << 62))
234 # define FIXWVABLE(wi) (POSFIXWVABLE(wi) && NEGFIXWVABLE(wi))
235 # define WINT2FIXWV(i) WIDEVAL_WRAP(INT64toFIXWV(i))
236 # define FIXWV2WINT(w) FIXWVtoINT64(WIDEVAL_GET(w))
242 # define WIDEVALUE_IS_WIDER 0
243 # define UWIDEINT_MAX ULONG_MAX
244 # define WIDEINT_MAX LONG_MAX
245 # define WIDEINT_MIN LONG_MIN
246 # define FIXWINT_P(v) FIXNUM_P(v)
247 # define FIXWV_MAX FIXNUM_MAX
248 # define FIXWV_MIN FIXNUM_MIN
249 # define FIXWVABLE(i) FIXABLE(i)
250 # define WINT2FIXWV(i) WIDEVAL_WRAP(LONG2FIX(i))
251 # define FIXWV2WINT(w) FIX2LONG(WIDEVAL_GET(w))
254 #define POSFIXWVABLE(wi) ((wi) < FIXWV_MAX+1)
255 #define NEGFIXWVABLE(wi) ((wi) >= FIXWV_MIN)
256 #define FIXWV_P(w) FIXWINT_P(WIDEVAL_GET(w))
259 #ifdef STRUCT_WIDEVAL
265 # define WIDEVAL_GET(w) ((w).value)
268 # define WIDEVAL_WRAP(v) (v)
269 # define WIDEVAL_GET(w) (w)
272 #if WIDEVALUE_IS_WIDER
281 # define WINT2WV(wi) wint2wv(wi)
283 # define WINT2WV(wi) WIDEVAL_WRAP(LONG2NUM(wi))
289 #if WIDEVALUE_IS_WIDER
298 #if WIDEVALUE_IS_WIDER
303 if (d & ~(
BDIGIT)0xffff) {
327 rb_big_abs_find_maxbit(
VALUE big)
333 while (0 < len && ds[len-1] == 0)
344 rb_big_abs_find_minbit(
VALUE big)
351 for (i = 0; i <
len; i++)
371 maxbit = rb_big_abs_find_maxbit(v);
394 #if WIDEVALUE_IS_WIDER
400 return v2w_bignum(v);
409 #if WIDEVALUE_IS_WIDER
423 #if WIDEVALUE_IS_WIDER
440 #define wne(x,y) (!weq((x),(y)))
441 #define wlt(x,y) (wcmp((x),(y)) < 0)
442 #define wgt(x,y) (wcmp((x),(y)) > 0)
443 #define wle(x,y) (wcmp((x),(y)) <= 0)
444 #define wge(x,y) (wcmp((x),(y)) >= 0)
450 #if WIDEVALUE_IS_WIDER
466 #if WIDEVALUE_IS_WIDER
483 if (x == 0 || y == 0) {
524 #if WIDEVALUE_IS_WIDER
544 #if WIDEVALUE_IS_WIDER
566 #define wmulquo(x,y,z) ((WIDEVAL_GET(y) == WIDEVAL_GET(z)) ? (x) : wquo(wmul((x),(y)),(z)))
567 #define wmulquoll(x,y,z) (((y) == (z)) ? (x) : wquo(wmul((x),WINT2WV(y)),WINT2WV(z)))
573 #if WIDEVALUE_IS_WIDER
720 #ifndef TYPEOF_TIMEVAL_TV_SEC
721 # define TYPEOF_TIMEVAL_TV_SEC time_t
723 #ifndef TYPEOF_TIMEVAL_TV_USEC
724 # if INT_MAX >= 1000000
725 # define TYPEOF_TIMEVAL_TV_USEC int
727 # define TYPEOF_TIMEVAL_TV_USEC long
731 #if SIZEOF_TIME_T == SIZEOF_LONG
733 #elif SIZEOF_TIME_T == SIZEOF_INT
735 #elif SIZEOF_TIME_T == SIZEOF_LONG_LONG
738 # error cannot find integer type which size is same as time_t.
741 #define TIMET_MAX (~(time_t)0 <= 0 ? (time_t)((~(unsigned_time_t)0) >> 1) : (time_t)(~(unsigned_time_t)0))
742 #define TIMET_MIN (~(time_t)0 <= 0 ? (time_t)(((unsigned_time_t)1) << (sizeof(time_t) * CHAR_BIT - 1)) : (time_t)0)
758 #if WIDEVALUE_IS_WIDER
776 #if WIDEVALUE_IS_WIDER
805 #if WIDEVALUE_IS_WIDER
819 return v2w(TIMET2NUM(t));
821 #define TIMET2WV(t) timet2wv(t)
826 #if WIDEVALUE_IS_WIDER
842 return NUM2TIMET(
w2v(w));
844 #define WV2TIMET(t) wv2timet(t)
861 static int tmcmp(
struct tm *
a,
struct tm *
b);
863 static const char *
find_time_t(
struct tm *tptr,
int utc_p, time_t *
tp);
868 #define leap_year_v_p(y) leap_year_p(NUM2LONG(mod((y), INT2FIX(400))))
871 #define rb_gmtime_r(t, tm) gmtime_r((t), (tm))
872 #define rb_localtime_r(t, tm) localtime_r((t), (tm))
874 static inline struct tm *
877 struct tm *
t = gmtime(tp);
882 static inline struct tm *
885 struct tm *
t = localtime(tp);
894 #if defined __APPLE__ && defined __LP64__
895 if (*t != (time_t)(
int)*t)
return NULL;
898 #if defined(HAVE_MKTIME) && defined(LOCALTIME_OVERFLOW_PROBLEM)
904 # if defined(HAVE_STRUCT_TM_TM_GMTOFF)
905 gmtoff1 = result->tm_gmtoff;
908 # if defined(HAVE_STRUCT_TM_TM_GMTOFF)
909 gmtoff2 = tmp.tm_gmtoff;
911 if (*t + gmtoff1 != t2 + gmtoff2)
917 #define LOCALTIME(tm, result) (tzset(),rb_localtime_r2((tm), &(result)))
919 #if !defined(HAVE_STRUCT_TM_TM_GMTOFF)
924 #if defined(HAVE_TIMEGM) && defined(LOCALTIME_OVERFLOW_PROBLEM)
927 time_t t2 = timegm(&tmp);
934 # define GMTIME(tm, result) rb_gmtime_r2((tm), &(result))
942 -1 + 31 + 28 + 31 + 30,
943 -1 + 31 + 28 + 31 + 30 + 31,
944 -1 + 31 + 28 + 31 + 30 + 31 + 30,
945 -1 + 31 + 28 + 31 + 30 + 31 + 30 + 31,
946 -1 + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31,
947 -1 + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30,
948 -1 + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31,
949 -1 + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30
957 -1 + 31 + 29 + 31 + 30,
958 -1 + 31 + 29 + 31 + 30 + 31,
959 -1 + 31 + 29 + 31 + 30 + 31 + 30,
960 -1 + 31 + 29 + 31 + 30 + 31 + 30 + 31,
961 -1 + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31,
962 -1 + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30,
963 -1 + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31,
964 -1 + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30
969 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
972 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
978 int tm_year_mod400 = (
int)
MOD(tm_year, 400);
979 int tm_yday = tm_mday;
982 tm_yday += leap_year_yday_offset[tm_mon];
984 tm_yday += common_year_yday_offset[tm_mon];
1018 +
DIV(year_mod400 - 69, 4)
1019 -
DIV(year_mod400 - 1, 100)
1020 + (year_mod400 + 299) / 400;
1035 const char *
s = (
const char *)*key;
1036 const char **
ret = (
const char **)arg;
1039 *ret = (
const char *)*value;
1062 const int *yday_offset;
1076 vtm->
wday = (wday + 4) % 7;
1079 vtm->
sec = n % 60; n = n / 60;
1080 vtm->
min = n % 60; n = n / 60;
1097 if (30*365+7+31+29-1 <= n) {
1111 x = n / (365*100 + 24);
1112 n = n % (365*100 + 24);
1114 if (30*365+7+31+29-1 <= n) {
1124 x = n / (365*4 + 1);
1125 n = n % (365*4 + 1);
1127 if (365*2+31+29-1 <= n) {
1128 if (n < 365*2+366) {
1150 for (i = 0; i < 12; i++) {
1151 if (yday_offset[i] < n) {
1153 vtm->
mday = n - yday_offset[
i];
1166 #if defined(HAVE_STRUCT_TM_TM_GMTOFF)
1170 int gmtoff_sec, gmtoff_min, gmtoff_hour, gmtoff_day;
1177 if (t->tm_gmtoff < 0) {
1179 gmtoff = -t->tm_gmtoff;
1183 gmtoff = t->tm_gmtoff;
1185 gmtoff_sec = (
int)(gmtoff % 60);
1186 gmtoff = gmtoff / 60;
1187 gmtoff_min = (
int)(gmtoff % 60);
1188 gmtoff = gmtoff / 60;
1189 gmtoff_hour = (
int)gmtoff;
1193 gmtoff_hour *= sign;
1200 result->tm_sec += gmtoff_sec;
1201 if (result->tm_sec < 0) {
1202 result->tm_sec += 60;
1205 if (60 <= result->tm_sec) {
1206 result->tm_sec -= 60;
1211 result->tm_min += gmtoff_min;
1212 if (result->tm_min < 0) {
1213 result->tm_min += 60;
1216 if (60 <= result->tm_min) {
1217 result->tm_min -= 60;
1222 result->tm_hour += gmtoff_hour;
1223 if (result->tm_hour < 0) {
1224 result->tm_hour += 24;
1227 if (24 <= result->tm_hour) {
1228 result->tm_hour -= 24;
1234 if (gmtoff_day < 0) {
1235 if (result->tm_yday == 0) {
1236 result->tm_mday = 31;
1237 result->tm_mon = 11;
1239 result->tm_yday =
leap_year_p(result->tm_year + 1900) ? 365 : 364;
1241 else if (result->tm_mday == 1) {
1242 const int *days_in_month =
leap_year_p(result->tm_year + 1900) ?
1243 leap_year_days_in_month :
1246 result->tm_mday = days_in_month[result->tm_mon];
1253 result->tm_wday = (result->tm_wday + 6) % 7;
1257 if (result->tm_yday == (leap ? 365 : 364)) {
1260 result->tm_mday = 1;
1261 result->tm_yday = 0;
1263 else if (result->tm_mday == (leap ? leap_year_days_in_month :
1264 common_year_days_in_month)[result->tm_mon]) {
1266 result->tm_mday = 1;
1273 result->tm_wday = (result->tm_wday + 1) % 7;
1276 result->tm_isdst = 0;
1277 result->tm_gmtoff = 0;
1278 #if defined(HAVE_TM_ZONE)
1279 result->tm_zone = (
char *)
"UTC";
1283 return GMTIME(timep, *result);
1299 if (this_year == 0) {
1308 this_year = tm->tm_year;
1310 if (
TIMET_MAX - now < (time_t)(366*86400))
1313 known_leap_seconds_limit = now + (time_t)(366*86400);
1319 vtm.
mon = result.tm_mon + 1;
1320 vtm.
mday = result.tm_mday;
1321 vtm.
hour = result.tm_hour;
1322 vtm.
min = result.tm_min;
1323 vtm.
sec = result.tm_sec;
1355 tm.tm_mon = vtm->
mon - 1;
1356 tm.tm_mday = vtm->
mday;
1357 tm.tm_hour = vtm->
hour;
1358 tm.tm_min = vtm->
min;
1359 tm.tm_sec = vtm->
sec;
1396 result->
mon = tm.tm_mon + 1;
1397 result->
mday = tm.tm_mday;
1398 result->
hour = tm.tm_hour;
1399 result->
min = tm.tm_min;
1400 result->
sec = tm.tm_sec;
1403 result->
wday = tm.tm_wday;
1404 result->
yday = tm.tm_yday+1;
1405 result->
isdst = tm.tm_isdst;
1406 result->
zone =
"UTC";
1448 { 2034, 2035, 2036, 2031, 2032, 2027, 2033 },
1449 { 2026, 2027, 2033, 2034, 2035, 2030, 2031 },
1450 { 2026, 2032, 2033, 2034, 2035, 2030, 2036 },
1451 { 2035, 2030, 2036, 2026, 2032, 2033, 2034 },
1452 { 2033, 2034, 2035, 2030, 2036, 2026, 2032 },
1453 { 2036, 2026, 2032, 2033, 2034, 2035, 2030 },
1454 { 2035, 2030, 2036, 2026, 2032, 2033, 2034 },
1455 { 2032, 2033, 2034, 2035, 2030, 2036, 2026 },
1456 { 2030, 2036, 2026, 2032, 2033, 2034, 2035 },
1457 { 2034, 2035, 2030, 2036, 2026, 2032, 2033 },
1458 { 2026, 2032, 2033, 2034, 2035, 2030, 2036 },
1459 { 2030, 2036, 2026, 2032, 2033, 2034, 2035 },
1489 2032, 2016, 2028, 2012, 2024, 2036, 2020,
1498 a = (14 - month) / 12;
1499 y = year + 4800 -
a;
1500 m = month + 12 * a - 3;
1501 wday = day + (153*m+2)/5 + 365*y + y/4 - y/100 + y/400 + 2;
1524 # if defined(NEGATIVE_TIME_T)
1525 # if SIZEOF_TIME_T <= 4
1527 # define THE_TIME_OLD_ENOUGH ((time_t)0x80000000)
1531 # define THE_TIME_OLD_ENOUGH ((time_t)(1600-1970)*366*24*60*60)
1535 isdst = tm.tm_isdst;
1542 isdst = tm.tm_isdst;
1560 vtm2.
year =
INT2FIX(compat_leap_month_table[wday]);
1562 vtm2.
year =
INT2FIX(compat_common_month_table[vtm_utc->
mon-1][wday]);
1565 t = NUM2TIMET(timev);
1569 *isdst_ret = tm.tm_isdst;
1577 static time_t now = 0;
1578 static long now_gmtoff = 0;
1579 static const char *now_zone =
"UTC";
1585 *isdst_ret = tm.tm_isdst;
1587 *zone_ret = now_zone;
1597 off = vtm1->
sec - vtm2->
sec;
1598 off += (vtm1->
min - vtm2->
min) * 60;
1599 off += (vtm1->
hour - vtm2->
hour) * 3600;
1601 off +=
lt(vtm1->
year, vtm2->
year) ? -24*3600 : 24*3600;
1602 else if (vtm1->
mon != vtm2->
mon)
1603 off += vtm1->
mon < vtm2->
mon ? -24*3600 : 24*3600;
1605 off += vtm1->
mday < vtm2->
mday ? -24*3600 : 24*3600;
1617 struct vtm vtm1, vtm2;
1622 if (l < INT_MIN || INT_MAX < l)
1624 tm.tm_year = (
int)l;
1633 tm.tm_mon = vtm->
mon-1;
1634 tm.tm_mday = vtm->
mday;
1635 tm.tm_hour = vtm->
hour;
1636 tm.tm_min = vtm->
min;
1637 tm.tm_sec = vtm->
sec;
1638 tm.tm_isdst = vtm->
isdst;
1673 if (
weq(timew1, timew2))
1698 #if defined(HAVE_STRUCT_TM_TM_GMTOFF)
1699 *gmtoff = tm.tm_gmtoff;
1708 if (l->tm_year != u->tm_year)
1709 off = l->tm_year < u->tm_year ? -1 : 1;
1710 else if (l->tm_mon != u->tm_mon)
1711 off = l->tm_mon < u->tm_mon ? -1 : 1;
1712 else if (l->tm_mday != u->tm_mday)
1713 off = l->tm_mday < u->tm_mday ? -1 : 1;
1716 off = off * 24 + l->tm_hour - u->tm_hour;
1717 off = off * 60 + l->tm_min - u->tm_min;
1718 off = off * 60 + l->tm_sec - u->tm_sec;
1723 #if defined(HAVE_TM_ZONE)
1725 #elif defined(HAVE_TZNAME) && defined(HAVE_DAYLIGHT)
1727 *zone =
zone_str(tzname[daylight && tm.tm_isdst]);
1731 strftime(buf,
sizeof(buf),
"%Z", &tm);
1747 #if WIDEVALUE_IS_WIDER && SIZEOF_TIME_T < SIZEOF_INT64_T
1756 #if SIZEOF_TIME_T == SIZEOF_INT64_T
1759 if (~(time_t)0 <= 0) {
1769 timexv =
w2v(timew);
1795 result->
mon = tm.tm_mon + 1;
1796 result->
mday = tm.tm_mday;
1797 result->
hour = tm.tm_hour;
1798 result->
min = tm.tm_min;
1799 result->
sec = tm.tm_sec;
1801 result->
wday = tm.tm_wday;
1802 result->
yday = tm.tm_yday+1;
1803 result->
isdst = tm.tm_isdst;
1805 result->
zone = zone;
1819 result->
isdst = isdst;
1820 result->
zone = zone;
1832 #define GetTimeval(obj, tobj) ((tobj) = get_timeval(obj))
1833 #define GetNewTimeval(obj, tobj) ((tobj) = get_new_timeval(obj))
1835 #define IsTimeval(obj) rb_typeddata_is_kind_of((obj), &time_data_type)
1836 #define TIME_INIT_P(tobj) ((tobj)->gmt != -1)
1838 #define TIME_UTC_P(tobj) ((tobj)->gmt == 1)
1839 #define TIME_SET_UTC(tobj) ((tobj)->gmt = 1)
1841 #define TIME_LOCALTIME_P(tobj) ((tobj)->gmt == 0)
1842 #define TIME_SET_LOCALTIME(tobj) ((tobj)->gmt = 0)
1844 #define TIME_FIXOFF_P(tobj) ((tobj)->gmt == 2)
1845 #define TIME_SET_FIXOFF(tobj, off) \
1847 (tobj)->vtm.utc_offset = (off), \
1848 (tobj)->vtm.zone = NULL)
1850 #define TIME_COPY_GMT(tobj1, tobj2) \
1851 ((tobj1)->gmt = (tobj2)->gmt, \
1852 (tobj1)->vtm.utc_offset = (tobj2)->vtm.utc_offset, \
1853 (tobj1)->vtm.zone = (tobj2)->vtm.zone)
1856 #define MAKE_TM(time, tobj) \
1858 if ((tobj)->tm_got == 0) { \
1859 time_get_tm((time), (tobj)); \
1878 if (tobj)
xfree(tobj);
1997 #ifdef HAVE_CLOCK_GETTIME
1998 if (clock_gettime(CLOCK_REALTIME, &ts) == -1) {
2057 subsec =
neg(subsec);
2086 if (60 <= vtm->
sec) {
2097 if (60 <= vtm->
min) {
2104 if (vtm->
hour < 0) {
2108 if (24 <= vtm->
hour) {
2116 if (vtm->
mon == 1 && vtm->
mday == 1) {
2122 else if (vtm->
mday == 1) {
2124 leap_year_days_in_month :
2127 vtm->
mday = days_in_month[vtm->
mon-1];
2138 if (vtm->
mon == 12 && vtm->
mday == 31) {
2144 else if (vtm->
mday == (leap ? leap_year_days_in_month :
2145 common_year_days_in_month)[vtm->
mon-1]) {
2172 if (s[6] !=
':')
goto invalid_utc_offset;
2174 n += (s[7] * 10 + s[8] -
'0' * 11);
2176 if (s[0] !=
'+' && s[0] !=
'-')
goto invalid_utc_offset;
2178 if (s[3] !=
':')
goto invalid_utc_offset;
2182 goto invalid_utc_offset;
2184 n += (s[1] * 10 + s[2] -
'0' * 11) * 3600;
2185 n += (s[4] * 10 + s[5] -
'0' * 11) * 60;
2207 rb_scan_args(argc, argv,
"16", &v[0],&v[1],&v[2],&v[3],&v[4],&v[5],&v[6]);
2312 time_t
tmp, sec = *secp;
2315 if (nsec >= 1000000000) {
2316 tmp = sec + nsec / 1000000000;
2318 if (sec > 0 && tmp < 0) {
2324 tmp = sec +
NDIV(nsec,1000000000);
2325 nsec =
NMOD(nsec,1000000000);
2326 if (sec < 0 && tmp > 0) {
2331 #ifndef NEGATIVE_TIME_T
2367 if (usec >= 1000000) {
2368 long sec2 = usec / 1000000;
2372 usec -= sec2 * 1000000;
2375 else if (usec <= 1000000) {
2376 long sec2 = usec / 1000000;
2380 usec -= sec2 * 1000000;
2413 const char *tstr = interval ?
"time interval" :
"time";
2416 #ifndef NEGATIVE_TIME_T
2420 switch (
TYPE(num)) {
2422 t.
tv_sec = NUM2TIMET(num);
2423 if (interval && t.
tv_sec < 0)
2438 else if ((t.
tv_nsec = (
int)(-d*1e9+0.5)) > 0) {
2450 t.
tv_sec = NUM2TIMET(num);
2451 if (interval && t.
tv_sec < 0)
2463 if (interval && t.
tv_sec < 0)
2593 "jan",
"feb",
"mar",
"apr",
"may",
"jun",
2594 "jul",
"aug",
"sep",
"oct",
"nov",
"dec",
2654 for (i=0; i<12; i++) {
2664 if (
'0' <= c && c <=
'9') {
2685 if ( vtm->
mon < 1 || vtm->
mon > 12
2688 || (vtm->
hour == 24 && (vtm->
min > 0 || vtm->
sec > 0))
2689 || vtm->
min < 0 || vtm->
min > 59
2690 || vtm->
sec < 0 || vtm->
sec > 60
2725 rb_scan_args(argc, argv,
"17", &v[0],&v[1],&v[2],&v[3],&v[4],&v[5],&v[6],&v[7]);
2752 if (!
NIL_P(v[6]) && argc == 7) {
2767 return ((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0);
2773 long tm_year = tm->tm_year;
2774 int tm_yday = tm->tm_mday;
2776 tm_yday += leap_year_yday_offset[tm->tm_mon];
2778 tm_yday += common_year_yday_offset[tm->tm_mon];
2786 return tm->tm_sec + tm->tm_min*60 + tm->tm_hour*3600 +
2790 DIV(tm_year-1,100) +
2791 DIV(tm_year+299,400))*86400;
2795 #define DEBUG_FIND_TIME_NUMGUESS
2796 #define DEBUG_GUESSRANGE
2799 #ifdef DEBUG_GUESSRANGE
2800 #define DEBUG_REPORT_GUESSRANGE fprintf(stderr, "find time guess range: %ld - %ld : %lu\n", guess_lo, guess_hi, (unsigned_time_t)(guess_hi-guess_lo))
2802 #define DEBUG_REPORT_GUESSRANGE
2805 #ifdef DEBUG_FIND_TIME_NUMGUESS
2806 #define DEBUG_FIND_TIME_NUMGUESS_INC find_time_numguess++,
2807 static unsigned long long find_time_numguess;
2809 static VALUE find_time_numguess_getter(
void)
2811 return ULL2NUM(find_time_numguess);
2814 #define DEBUG_FIND_TIME_NUMGUESS_INC
2820 time_t guess, guess0, guess_lo, guess_hi;
2821 struct tm *tm, tm0, tm_lo, tm_hi;
2828 #define GUESS(p) (DEBUG_FIND_TIME_NUMGUESS_INC (utc_p ? gmtime_with_leapsecond((p), &result) : LOCALTIME((p), result)))
2833 find_dst = 0 < tptr->tm_isdst;
2835 #if defined(HAVE_MKTIME)
2837 if (!utc_p && (guess = mktime(&tm0)) != -1) {
2839 if (tm &&
tmcmp(tptr, tm) == 0) {
2846 if (tm0.tm_mon < 0) {
2853 else if (11 < tm0.tm_mon) {
2860 else if (tm0.tm_mday < 1) {
2867 leap_year_days_in_month :
2868 common_year_days_in_month)[tm0.tm_mon]) < tm0.tm_mday) {
2874 else if (tm0.tm_hour < 0) {
2879 else if (23 < tm0.tm_hour) {
2884 else if (tm0.tm_min < 0) {
2888 else if (59 < tm0.tm_min) {
2892 else if (tm0.tm_sec < 0) {
2895 else if (60 < tm0.tm_sec) {
2903 d =
tmcmp(tptr, tm);
2904 if (d == 0) {
goto found; }
2907 guess -= 24 * 60 * 60;
2911 guess += 24 * 60 * 60;
2914 if (guess_lo < guess && guess < guess_hi && (tm =
GUESS(&guess)) !=
NULL) {
2915 d =
tmcmp(tptr, tm);
2916 if (d == 0) {
goto found; }
2925 tm =
GUESS(&guess_lo);
2926 if (!tm)
goto error;
2927 d =
tmcmp(tptr, tm);
2928 if (d < 0)
goto out_of_range;
2929 if (d == 0) { guess = guess_lo;
goto found; }
2932 tm =
GUESS(&guess_hi);
2933 if (!tm)
goto error;
2934 d =
tmcmp(tptr, tm);
2935 if (d > 0)
goto out_of_range;
2936 if (d == 0) { guess = guess_hi;
goto found; }
2943 while (guess_lo + 1 < guess_hi) {
2946 guess = guess_lo / 2 + guess_hi / 2;
2947 if (guess <= guess_lo)
2948 guess = guess_lo + 1;
2949 else if (guess >= guess_hi)
2950 guess = guess_hi - 1;
2956 guess = guess_hi - (guess0_hi - guess0);
2957 if (guess == guess_hi)
2961 else if (status == 2) {
2963 guess = guess_lo + (guess0 - guess0_lo);
2964 if (guess == guess_lo)
2968 if (guess <= guess_lo || guess_hi <= guess) {
2970 #ifdef DEBUG_GUESSRANGE
2971 if (guess <= guess_lo) fprintf(stderr,
"too small guess: %ld <= %ld\n", guess, guess_lo);
2972 if (guess_hi <= guess) fprintf(stderr,
"too big guess: %ld <= %ld\n", guess_hi, guess);
2979 if (!tm)
goto error;
2981 d =
tmcmp(tptr, tm);
2999 guess2 = guess - 2 * 60 * 60;
3002 if (tptr->tm_hour != (tm->tm_hour + 2) % 24 ||
3003 tptr->tm_min != tm->tm_min ||
3004 tptr->tm_sec != tm->tm_sec) {
3005 guess2 -= (tm->tm_hour - tptr->tm_hour) * 60 * 60 +
3006 (tm->tm_min - tptr->tm_min) * 60 +
3007 (tm->tm_sec - tptr->tm_sec);
3008 if (tptr->tm_mday != tm->tm_mday)
3009 guess2 += 24 * 60 * 60;
3010 if (guess != guess2) {
3012 if (tm &&
tmcmp(tptr, tm) == 0) {
3024 guess2 = guess + 2 * 60 * 60;
3027 if ((tptr->tm_hour + 2) % 24 != tm->tm_hour ||
3028 tptr->tm_min != tm->tm_min ||
3029 tptr->tm_sec != tm->tm_sec) {
3030 guess2 -= (tm->tm_hour - tptr->tm_hour) * 60 * 60 +
3031 (tm->tm_min - tptr->tm_min) * 60 +
3032 (tm->tm_sec - tptr->tm_sec);
3033 if (tptr->tm_mday != tm->tm_mday)
3034 guess2 -= 24 * 60 * 60;
3035 if (guess != guess2) {
3037 if (tm &&
tmcmp(tptr, tm) == 0) {
3062 tptr_tm_yday =
calc_tm_yday(tptr->tm_year, tptr->tm_mon, tptr->tm_mday);
3065 ((tptr->tm_year - tm_lo.tm_year) * 365 +
3066 ((tptr->tm_year-69)/4) -
3067 ((tptr->tm_year-1)/100) +
3068 ((tptr->tm_year+299)/400) -
3069 ((tm_lo.tm_year-69)/4) +
3070 ((tm_lo.tm_year-1)/100) -
3071 ((tm_lo.tm_year+299)/400) +
3073 tm_lo.tm_yday) * 86400 +
3074 (tptr->tm_hour - tm_lo.tm_hour) * 3600 +
3075 (tptr->tm_min - tm_lo.tm_min) * 60 +
3076 (tptr->tm_sec - (tm_lo.tm_sec == 60 ? 59 : tm_lo.tm_sec));
3081 return "time out of range";
3084 return "gmtime/localtime error";
3092 else if (a->
mon != b->
mon)
3093 return a->
mon < b->
mon ? -1 : 1;
3098 else if (a->
min != b->
min)
3099 return a->
min < b->
min ? -1 : 1;
3100 else if (a->
sec != b->
sec)
3101 return a->
sec < b->
sec ? -1 : 1;
3111 if (a->tm_year != b->tm_year)
3112 return a->tm_year < b->tm_year ? -1 : 1;
3113 else if (a->tm_mon != b->tm_mon)
3114 return a->tm_mon < b->tm_mon ? -1 : 1;
3115 else if (a->tm_mday != b->tm_mday)
3116 return a->tm_mday < b->tm_mday ? -1 : 1;
3117 else if (a->tm_hour != b->tm_hour)
3118 return a->tm_hour < b->tm_hour ? -1 : 1;
3119 else if (a->tm_min != b->tm_min)
3120 return a->tm_min < b->tm_min ? -1 : 1;
3121 else if (a->tm_sec != b->tm_sec)
3122 return a->tm_sec < b->tm_sec ? -1 : 1;
3405 if (n == 0)
return INT2FIX(0);
3841 rb_warn(
"Time#succ is obsolete; use time + 1");
3849 #define time_succ rb_time_succ
4081 #define wday_p(n) {\
4082 struct time_object *tobj;\
4083 GetTimeval(time, tobj);\
4084 MAKE_TM(time, tobj);\
4085 return (tobj->vtm.wday == (n)) ? Qtrue : Qfalse;\
4352 #define SMALLBUF 100
4374 if (len != 0 || (**buf ==
'\0' &&
errno != ERANGE))
return len;
4375 for (size=1024; ; size*=2) {
4381 len =
rb_strftime(*buf, size, format, enc, vtm, timev, gmt);
4391 if (size >= 1024 * flen) {
4412 if (buf != buffer)
xfree(buf);
4621 rb_warning(
"strftime called with empty format string");
4623 else if (memchr(fmt,
'\0', len)) {
4625 const char *
p =
fmt, *pe = fmt +
len;
4633 if (buf != buffer) {
4637 for (fmt = p; p < pe && !*
p; ++
p);
4647 if (buf != buffer)
xfree(buf);
4672 if (year < 1900 || 1900+0xffff < year)
4699 for (i=0; i<4; i++) {
4700 buf[
i] = (
unsigned char)p;
4703 for (i=4; i<8; i++) {
4704 buf[
i] = (
unsigned char)s;
4729 int len = (
int)
sizeof(buf);
4730 buf[1] = (char)((nsec % 10) << 4);
4732 buf[0] = (char)(nsec % 10);
4734 buf[0] |= (char)((nsec % 10) << 4);
4776 VALUE submicro, nano_num, nano_den, offset,
zone;
4782 #define get_attr(attr, iffound) \
4783 attr = rb_attr_get(str, id_##attr); \
4784 if (!NIL_P(attr)) { \
4787 st_delete(rb_generic_ivar_table(str), &data, 0); \
4806 for (i=0; i<4; i++) {
4809 for (i=4; i<8; i++) {
4810 s |= buf[
i]<<(8*(i-4));
4813 if ((p & (1UL<<31)) == 0) {
4823 gmt = (
int)((p >> 30) & 0x1);
4825 vtm.
year =
INT2FIX(((
int)(p >> 14) & 0xffff) + 1900);
4826 vtm.
mon = ((
int)(p >> 10) & 0xf) + 1;
4827 vtm.
mday = (
int)(p >> 5) & 0x1f;
4829 vtm.
min = (
int)(s >> 26) & 0x3f;
4830 vtm.
sec = (
int)(s >> 20) & 0x3f;
4836 usec = (long)(s & 0xfffff);
4841 if (nano_num !=
Qnil) {
4845 else if (submicro !=
Qnil) {
4853 if (10 <= (digit = ptr[0] >> 4))
goto end_submicro;
4854 nsec += digit * 100;
4855 if (10 <= (digit = ptr[0] & 0xf))
goto end_submicro;
4859 if (10 <= (digit = ptr[1] >> 4))
goto end_submicro;
4871 tobj->
timew = timew;
4875 else if (!
NIL_P(offset)) {
4988 #define rb_intern(str) rb_intern_const(str)
5089 #ifdef DEBUG_FIND_TIME_NUMGUESS
static const rb_data_type_t time_data_type
#define RB_TYPE_P(obj, type)
VALUE rb_big_modulo(VALUE x, VALUE y)
static VALUE quo(VALUE x, VALUE y)
static int cmp(VALUE x, VALUE y)
static int vtmcmp(struct vtm *a, struct vtm *b)
static time_t timegm_noleapsecond(struct tm *tm)
static VALUE w2v(wideval_t w)
VALUE rb_time_num_new(VALUE, VALUE)
static VALUE time_mon(VALUE time)
static VALUE time_to_r(VALUE time)
VALUE rb_ary_entry(VALUE ary, long offset)
int gettimeofday(struct timeval *, struct timezone *)
static int obj2int(VALUE obj)
static VALUE time_sunday(VALUE time)
static VALUE time_getlocaltime(int argc, VALUE *argv, VALUE time)
size_t strlen(const char *)
static struct timespec * timew2timespec_exact(wideval_t timew, struct timespec *ts)
VALUE rb_class_new_instance(int, VALUE *, VALUE)
const char * rb_obj_classname(VALUE)
static VALUE time_s_now(VALUE klass)
static VALUE time_utc_or_local(int argc, VALUE *argv, int utc_p, VALUE klass)
static int tmcmp(struct tm *a, struct tm *b)
#define rb_check_trusted(obj)
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
static VALUE time_utc_p(VALUE time)
static struct time_object * get_new_timeval(VALUE obj)
#define GetTimeval(obj, tobj)
static wideval_t timelocalw(struct vtm *vtm)
static void split_second(wideval_t timew, wideval_t *timew_p, VALUE *subsecx_p)
static VALUE obj2vint(VALUE obj)
VALUE rb_time_nano_new(time_t, long)
static VALUE time_minus(VALUE time1, VALUE time2)
static VALUE small_vtm_sub(struct vtm *vtm1, struct vtm *vtm2)
#define rb_check_frozen(obj)
RUBY_EXTERN VALUE rb_cTime
static VALUE time_hash(VALUE time)
static VALUE time_localtime_m(int argc, VALUE *argv, VALUE time)
static VALUE time_s_alloc(VALUE klass)
static VALUE time_get_tm(VALUE, struct time_object *)
static int calc_tm_yday(long tm_year, int tm_mon, int tm_mday)
VALUE rb_big_plus(VALUE x, VALUE y)
static VALUE time_sec(VALUE time)
void rb_define_private_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
static int leap_year_p(long y)
#define DEBUG_REPORT_GUESSRANGE
static struct tm * localtime_with_gmtoff_zone(const time_t *t, struct tm *result, long *gmtoff, const char **zone)
static VALUE time_gmtime(VALUE)
static VALUE time_monday(VALUE time)
VALUE rb_enc_str_new(const char *, long, rb_encoding *)
static const int common_year_days_in_month[]
#define TYPEOF_TIMEVAL_TV_USEC
static VALUE time_init(int argc, VALUE *argv, VALUE time)
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
void rb_raise(VALUE exc, const char *fmt,...)
static void vtm_add_offset(struct vtm *vtm, VALUE off)
static VALUE time_round(int argc, VALUE *argv, VALUE time)
static VALUE add(VALUE x, VALUE y)
VALUE rb_obj_class(VALUE)
st_table * st_init_strtable(void)
static VALUE time_plus(VALUE time1, VALUE time2)
static wideval_t wsub(wideval_t wx, wideval_t wy)
VALUE rb_ary_new3(long n,...)
void rb_include_module(VALUE klass, VALUE module)
static VALUE time_utc_offset(VALUE time)
static VALUE time_usec(VALUE time)
static int long_mul(long x, long y, long *z)
static int compat_leap_month_table[7]
#define TIME_LOCALTIME_P(tobj)
static VALUE time_init_0(VALUE time)
static struct tm * rb_localtime_r2(const time_t *t, struct tm *result)
static size_t time_memsize(const void *tobj)
unsigned long unsigned_time_t
static wideval_t wadd(wideval_t wx, wideval_t wy)
static VALUE time_mload(VALUE time, VALUE str)
static VALUE time_wednesday(VALUE time)
static VALUE time_min(VALUE time)
static VALUE time_cmp(VALUE time1, VALUE time2)
int rb_cmpint(VALUE val, VALUE a, VALUE b)
static VALUE time_yday(VALUE time)
static size_t rb_strftime_alloc(char **buf, VALUE formatv, const char *format, rb_encoding *enc, struct vtm *vtm, wideval_t timew, int gmt)
static VALUE strftimev(const char *fmt, VALUE time, rb_encoding *enc)
VALUE rb_equal(VALUE, VALUE)
static int number_of_leap_seconds_known
static VALUE time_add(struct time_object *tobj, VALUE offset, int sign)
static VALUE time_new_timew(VALUE klass, wideval_t timew)
void rb_copy_generic_ivar(VALUE, VALUE)
static struct tm * rb_gmtime_r2(const time_t *t, struct tm *result)
static time_t wv2timet(wideval_t w)
int st_update(st_table *table, st_data_t key, st_update_callback_func *func, st_data_t arg)
VALUE rb_singleton_class(VALUE obj)
Returns the singleton class of obj.
static VALUE time_wday(VALUE time)
static wideval_t nsec2timew(time_t sec, long nsec)
static const char * find_time_t(struct tm *tptr, int utc_p, time_t *tp)
static VALUE time_asctime(VALUE time)
static VALUE time_s_at(int argc, VALUE *argv, VALUE klass)
static VALUE time_set_utc_offset(VALUE time, VALUE off)
unsigned long long uint64_t
#define GetNewTimeval(obj, tobj)
static wideval_t wmod(wideval_t wx, wideval_t wy)
#define TypedData_Get_Struct(obj, type, data_type, sval)
static VALUE time_load(VALUE klass, VALUE str)
#define StringValuePtr(v)
#define STRCASECMP(s1, s2)
#define get_attr(attr, iffound)
#define wmulquoll(x, y, z)
VALUE rb_str_to_inum(VALUE str, int base, int badcheck)
#define TIME_SET_UTC(tobj)
static int obj2subsecx(VALUE obj, VALUE *subsecx)
static VALUE mod(VALUE x, VALUE y)
#define LOCALTIME(tm, result)
VALUE rb_locale_str_new_cstr(const char *)
static VALUE time_saturday(VALUE time)
#define TIME_FIXOFF_P(tobj)
#define StringValueCStr(v)
static int wcmp(wideval_t wx, wideval_t wy)
static VALUE time_subsec(VALUE time)
VALUE rb_define_class(const char *name, VALUE super)
Defines a top-level class.
static struct vtm * localtimew(wideval_t timew, struct vtm *result)
VALUE rb_check_to_integer(VALUE, const char *)
static void time_arg(int argc, VALUE *argv, struct vtm *vtm)
void rb_sys_fail_str(VALUE mesg)
static wideval_t wdiv(wideval_t wx, wideval_t wy)
#define GMTIME(tm, result)
#define OBJ_INIT_COPY(obj, orig)
static const char * zone_str(const char *s)
static int calc_wday(int year, int month, int day)
static wideval_t wmul(wideval_t wx, wideval_t wy)
#define TIME_INIT_P(tobj)
static VALUE time_eql(VALUE time1, VALUE time2)
unsigned char buf[MIME_BUF_SIZE]
static struct tm * rb_gmtime_r(const time_t *tp, struct tm *result)
#define RBIGNUM_NEGATIVE_P(b)
void rb_num_zerodiv(void)
static VALUE guess_local_offset(struct vtm *vtm_utc, int *isdst_ret, const char **zone_ret)
VALUE rb_time_succ(VALUE)
VALUE rb_check_funcall(VALUE, ID, int, VALUE *)
static int weq(wideval_t wx, wideval_t wy)
#define RBIGNUM_DIGITS(b)
static VALUE time_localtime(VALUE)
static VALUE time_mday(VALUE time)
static void gmtimew_noleapsecond(wideval_t timew, struct vtm *vtm)
static VALUE utc_offset_arg(VALUE arg)
static VALUE time_to_i(VALUE time)
static void divmodv(VALUE n, VALUE d, VALUE *q, VALUE *r)
size_t rb_strftime_timespec(char *s, size_t maxsize, const char *format, rb_encoding *enc, const struct vtm *vtm, struct timespec *ts, int gmt)
VALUE rb_big_minus(VALUE x, VALUE y)
static VALUE time_to_s(VALUE time)
static VALUE time_to_f(VALUE time)
static const int leap_year_yday_offset[]
static VALUE time_getgmtime(VALUE time)
static struct tm * rb_localtime_r(const time_t *tp, struct tm *result)
static void validate_vtm(struct vtm *vtm)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
#define TIME_COPY_GMT(tobj1, tobj2)
static void time_free(void *tobj)
static wideval_t rb_time_magnify(wideval_t w)
static int min(int a, int b)
rb_encoding * rb_usascii_encoding(void)
static VALUE time_fixoff(VALUE)
static VALUE num_exact(VALUE v)
VALUE rb_obj_untaint(VALUE)
VALUE rb_big_mul(VALUE x, VALUE y)
static VALUE time_init_1(int argc, VALUE *argv, VALUE time)
static int wi_mul(wideint_t x, wideint_t y, wideint_t *z)
static st_table * zone_table
static struct timespec time_timespec(VALUE num, int interval)
static void validate_utc_offset(VALUE utc_offset)
static VALUE sub(VALUE x, VALUE y)
static int timew_out_of_timet_range(wideval_t timew)
VALUE rb_time_new(time_t, long)
static VALUE mul(VALUE x, VALUE y)
void rb_sys_fail(const char *mesg)
static struct vtm * gmtimew(wideval_t timew, struct vtm *result)
static long usec2subsecx(VALUE obj)
static int month_arg(VALUE arg)
static VALUE time_tuesday(VALUE time)
static wideval_t rb_time_unmagnify(wideval_t w)
static wideval_t v2w(VALUE v)
static VALUE time_to_a(VALUE time)
static VALUE time_thursday(VALUE time)
#define MEMCPY(p1, p2, type, n)
static const int common_year_yday_offset[]
static struct timeval time_timeval(VALUE num, int interval)
static VALUE time_strftime(VALUE time, VALUE format)
#define rb_enc_str_asciicompat_p(str)
static wideval_t timegmw_noleapsecond(struct vtm *vtm)
VALUE rb_ivar_set(VALUE, ID, VALUE)
static VALUE time_hour(VALUE time)
static time_t known_leap_seconds_limit
VALUE rb_str_cat(VALUE, const char *, long)
rb_encoding * rb_enc_get(VALUE obj)
struct timeval rb_time_interval(VALUE num)
#define TYPEOF_TIMEVAL_TV_SEC
#define TIME_SET_LOCALTIME(tobj)
static VALUE time_mdump(VALUE time)
static void time_mark(void *ptr)
VALUE rb_check_array_type(VALUE ary)
#define TIME_SET_FIXOFF(tobj, off)
static VALUE time_isdst(VALUE time)
static VALUE time_dup(VALUE time)
#define TypedData_Make_Struct(klass, type, data_type, sval)
static VALUE time_s_mkutc(int argc, VALUE *argv, VALUE klass)
static wideval_t timespec2timew(struct timespec *ts)
#define MAKE_TM(time, tobj)
RUBY_EXTERN VALUE rb_cObject
static struct tm * gmtime_with_leapsecond(const time_t *timep, struct tm *result)
static void wmuldivmod(wideval_t wx, wideval_t wy, wideval_t wz, wideval_t *wq, wideval_t *wr)
int rb_respond_to(VALUE, ID)
static int compat_common_month_table[12][7]
static void time_overflow_p(time_t *secp, long *nsecp)
SIGNED_VALUE SIGNED_WIDEVALUE
void rb_define_virtual_variable(const char *, VALUE(*)(ANYARGS), void(*)(ANYARGS))
static void init_leap_second_info(void)
VALUE rb_str_new(const char *, long)
static VALUE time_friday(VALUE time)
static const int leap_year_days_in_month[]
static void wdivmod(wideval_t wn, wideval_t wd, wideval_t *wq, wideval_t *wr)
static struct timespec timew2timespec(wideval_t timew)
static VALUE time_zone(VALUE time)
void rb_warning(const char *fmt,...)
static wideval_t timet2wv(time_t t)
static void time_modify(VALUE time)
static VALUE time_s_mktime(int argc, VALUE *argv, VALUE klass)
static int zone_str_update(st_data_t *key, st_data_t *value, st_data_t arg, int existing)
static VALUE time_year(VALUE time)
struct timespec rb_time_timespec(VALUE time)
static VALUE rb_time_unmagnify_to_float(wideval_t w)
static VALUE time_init_copy(VALUE copy, VALUE time)
static VALUE time_nsec(VALUE time)
VALUE rb_invcmp(VALUE x, VALUE y)
VALUE rb_check_string_type(VALUE)
static const char months[][4]
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
static struct time_object * get_timeval(VALUE obj)
static int eq(VALUE x, VALUE y)
void rb_warn(const char *fmt,...)
static VALUE time_dump(int argc, VALUE *argv, VALUE time)
struct timeval rb_time_timeval(VALUE)
static wideval_t timegmw(struct vtm *vtm)
size_t rb_strftime(char *s, size_t maxsize, const char *format, rb_encoding *enc, const struct vtm *vtm, VALUE timev, int gmt)
static wideval_t wquo(wideval_t wx, wideval_t wy)