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
300 bdigit_find_maxbit(
BDIGIT d)
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)
862 static int tmcmp(
struct tm *a,
struct tm *b);
864 static const char *
find_time_t(
struct tm *tptr,
int utc_p, time_t *tp);
869 #define leap_year_v_p(y) leap_year_p(NUM2LONG(mod((y), INT2FIX(400))))
872 #define rb_gmtime_r(t, tm) gmtime_r((t), (tm))
873 #define rb_localtime_r(t, tm) localtime_r((t), (tm))
875 static inline struct tm *
878 struct tm *t = gmtime(tp);
883 static inline struct tm *
886 struct tm *t = localtime(tp);
895 #if defined __APPLE__ && defined __LP64__
896 if (*t != (time_t)(
int)*t)
return NULL;
899 #if defined(HAVE_MKTIME) && defined(LOCALTIME_OVERFLOW_PROBLEM)
905 # if defined(HAVE_STRUCT_TM_TM_GMTOFF)
906 gmtoff1 = result->tm_gmtoff;
909 # if defined(HAVE_STRUCT_TM_TM_GMTOFF)
910 gmtoff2 = tmp.tm_gmtoff;
912 if (*t + gmtoff1 != t2 + gmtoff2)
918 #define LOCALTIME(tm, result) (tzset(),rb_localtime_r2((tm), &(result)))
920 #if !defined(HAVE_STRUCT_TM_TM_GMTOFF)
925 #if defined(HAVE_TIMEGM) && defined(LOCALTIME_OVERFLOW_PROBLEM)
928 time_t t2 = timegm(&tmp);
935 # define GMTIME(tm, result) rb_gmtime_r2((tm), &(result))
943 -1 + 31 + 28 + 31 + 30,
944 -1 + 31 + 28 + 31 + 30 + 31,
945 -1 + 31 + 28 + 31 + 30 + 31 + 30,
946 -1 + 31 + 28 + 31 + 30 + 31 + 30 + 31,
947 -1 + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31,
948 -1 + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30,
949 -1 + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31,
950 -1 + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30
958 -1 + 31 + 29 + 31 + 30,
959 -1 + 31 + 29 + 31 + 30 + 31,
960 -1 + 31 + 29 + 31 + 30 + 31 + 30,
961 -1 + 31 + 29 + 31 + 30 + 31 + 30 + 31,
962 -1 + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31,
963 -1 + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30,
964 -1 + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31,
965 -1 + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30
970 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
973 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
979 int tm_year_mod400 = (int)
MOD(tm_year, 400);
980 int tm_yday = tm_mday;
983 tm_yday += leap_year_yday_offset[tm_mon];
985 tm_yday += common_year_yday_offset[tm_mon];
1019 +
DIV(year_mod400 - 69, 4)
1020 -
DIV(year_mod400 - 1, 100)
1021 + (year_mod400 + 299) / 400;
1036 const char *s = (
const char *)*key;
1037 const char **ret = (
const char **)arg;
1040 *ret = (
const char *)*value;
1063 const int *yday_offset;
1077 vtm->
wday = (wday + 4) % 7;
1080 vtm->
sec = n % 60; n = n / 60;
1081 vtm->
min = n % 60; n = n / 60;
1098 if (30*365+7+31+29-1 <= n) {
1112 x = n / (365*100 + 24);
1113 n = n % (365*100 + 24);
1115 if (30*365+7+31+29-1 <= n) {
1125 x = n / (365*4 + 1);
1126 n = n % (365*4 + 1);
1128 if (365*2+31+29-1 <= n) {
1129 if (n < 365*2+366) {
1151 for (i = 0; i < 12; i++) {
1152 if (yday_offset[i] < n) {
1154 vtm->
mday = n - yday_offset[
i];
1167 #if defined(HAVE_STRUCT_TM_TM_GMTOFF)
1171 int gmtoff_sec, gmtoff_min, gmtoff_hour, gmtoff_day;
1178 if (t->tm_gmtoff < 0) {
1180 gmtoff = -t->tm_gmtoff;
1184 gmtoff = t->tm_gmtoff;
1186 gmtoff_sec = (int)(gmtoff % 60);
1187 gmtoff = gmtoff / 60;
1188 gmtoff_min = (int)(gmtoff % 60);
1189 gmtoff = gmtoff / 60;
1190 gmtoff_hour = (int)gmtoff;
1194 gmtoff_hour *= sign;
1201 result->tm_sec += gmtoff_sec;
1202 if (result->tm_sec < 0) {
1203 result->tm_sec += 60;
1206 if (60 <= result->tm_sec) {
1207 result->tm_sec -= 60;
1212 result->tm_min += gmtoff_min;
1213 if (result->tm_min < 0) {
1214 result->tm_min += 60;
1217 if (60 <= result->tm_min) {
1218 result->tm_min -= 60;
1223 result->tm_hour += gmtoff_hour;
1224 if (result->tm_hour < 0) {
1225 result->tm_hour += 24;
1228 if (24 <= result->tm_hour) {
1229 result->tm_hour -= 24;
1235 if (gmtoff_day < 0) {
1236 if (result->tm_yday == 0) {
1237 result->tm_mday = 31;
1238 result->tm_mon = 11;
1240 result->tm_yday =
leap_year_p(result->tm_year + 1900) ? 365 : 364;
1242 else if (result->tm_mday == 1) {
1243 const int *days_in_month =
leap_year_p(result->tm_year + 1900) ?
1244 leap_year_days_in_month :
1247 result->tm_mday = days_in_month[result->tm_mon];
1254 result->tm_wday = (result->tm_wday + 6) % 7;
1258 if (result->tm_yday == (leap ? 365 : 364)) {
1261 result->tm_mday = 1;
1262 result->tm_yday = 0;
1264 else if (result->tm_mday == (leap ? leap_year_days_in_month :
1265 common_year_days_in_month)[result->tm_mon]) {
1267 result->tm_mday = 1;
1274 result->tm_wday = (result->tm_wday + 1) % 7;
1277 result->tm_isdst = 0;
1278 result->tm_gmtoff = 0;
1279 #if defined(HAVE_TM_ZONE)
1280 result->tm_zone = (
char *)
"UTC";
1284 return GMTIME(timep, *result);
1300 if (this_year == 0) {
1309 this_year = tm->tm_year;
1311 if (
TIMET_MAX - now < (time_t)(366*86400))
1314 known_leap_seconds_limit = now + (time_t)(366*86400);
1320 vtm.
mon = result.tm_mon + 1;
1321 vtm.
mday = result.tm_mday;
1322 vtm.
hour = result.tm_hour;
1323 vtm.
min = result.tm_min;
1324 vtm.
sec = result.tm_sec;
1356 tm.tm_mon = vtm->
mon - 1;
1357 tm.tm_mday = vtm->
mday;
1358 tm.tm_hour = vtm->
hour;
1359 tm.tm_min = vtm->
min;
1360 tm.tm_sec = vtm->
sec;
1397 result->
mon = tm.tm_mon + 1;
1398 result->
mday = tm.tm_mday;
1399 result->
hour = tm.tm_hour;
1400 result->
min = tm.tm_min;
1401 result->
sec = tm.tm_sec;
1404 result->
wday = tm.tm_wday;
1405 result->
yday = tm.tm_yday+1;
1406 result->
isdst = tm.tm_isdst;
1407 result->
zone =
"UTC";
1449 { 2034, 2035, 2036, 2031, 2032, 2027, 2033 },
1450 { 2026, 2027, 2033, 2034, 2035, 2030, 2031 },
1451 { 2026, 2032, 2033, 2034, 2035, 2030, 2036 },
1452 { 2035, 2030, 2036, 2026, 2032, 2033, 2034 },
1453 { 2033, 2034, 2035, 2030, 2036, 2026, 2032 },
1454 { 2036, 2026, 2032, 2033, 2034, 2035, 2030 },
1455 { 2035, 2030, 2036, 2026, 2032, 2033, 2034 },
1456 { 2032, 2033, 2034, 2035, 2030, 2036, 2026 },
1457 { 2030, 2036, 2026, 2032, 2033, 2034, 2035 },
1458 { 2034, 2035, 2030, 2036, 2026, 2032, 2033 },
1459 { 2026, 2032, 2033, 2034, 2035, 2030, 2036 },
1460 { 2030, 2036, 2026, 2032, 2033, 2034, 2035 },
1490 2032, 2016, 2028, 2012, 2024, 2036, 2020,
1499 a = (14 - month) / 12;
1500 y = year + 4800 - a;
1501 m = month + 12 * a - 3;
1502 wday = day + (153*m+2)/5 + 365*y + y/4 - y/100 + y/400 + 2;
1525 # if defined(NEGATIVE_TIME_T)
1526 # if SIZEOF_TIME_T <= 4
1528 # define THE_TIME_OLD_ENOUGH ((time_t)0x80000000)
1532 # define THE_TIME_OLD_ENOUGH ((time_t)(1600-1970)*366*24*60*60)
1536 isdst = tm.tm_isdst;
1543 isdst = tm.tm_isdst;
1561 vtm2.
year =
INT2FIX(compat_leap_month_table[wday]);
1563 vtm2.
year =
INT2FIX(compat_common_month_table[vtm_utc->
mon-1][wday]);
1566 t = NUM2TIMET(timev);
1570 *isdst_ret = tm.tm_isdst;
1578 static time_t now = 0;
1579 static long now_gmtoff = 0;
1580 static const char *now_zone =
"UTC";
1586 *isdst_ret = tm.tm_isdst;
1588 *zone_ret = now_zone;
1598 off = vtm1->
sec - vtm2->
sec;
1599 off += (vtm1->
min - vtm2->
min) * 60;
1600 off += (vtm1->
hour - vtm2->
hour) * 3600;
1602 off +=
lt(vtm1->
year, vtm2->
year) ? -24*3600 : 24*3600;
1603 else if (vtm1->
mon != vtm2->
mon)
1604 off += vtm1->
mon < vtm2->
mon ? -24*3600 : 24*3600;
1606 off += vtm1->
mday < vtm2->
mday ? -24*3600 : 24*3600;
1618 struct vtm vtm1, vtm2;
1623 if (l < INT_MIN || INT_MAX < l)
1625 tm.tm_year = (int)l;
1634 tm.tm_mon = vtm->
mon-1;
1635 tm.tm_mday = vtm->
mday;
1636 tm.tm_hour = vtm->
hour;
1637 tm.tm_min = vtm->
min;
1638 tm.tm_sec = vtm->
sec;
1639 tm.tm_isdst = vtm->
isdst;
1674 if (
weq(timew1, timew2))
1699 #if defined(HAVE_STRUCT_TM_TM_GMTOFF)
1700 *gmtoff = tm.tm_gmtoff;
1709 if (l->tm_year != u->tm_year)
1710 off = l->tm_year < u->tm_year ? -1 : 1;
1711 else if (l->tm_mon != u->tm_mon)
1712 off = l->tm_mon < u->tm_mon ? -1 : 1;
1713 else if (l->tm_mday != u->tm_mday)
1714 off = l->tm_mday < u->tm_mday ? -1 : 1;
1717 off = off * 24 + l->tm_hour - u->tm_hour;
1718 off = off * 60 + l->tm_min - u->tm_min;
1719 off = off * 60 + l->tm_sec - u->tm_sec;
1724 #if defined(HAVE_TM_ZONE)
1726 #elif defined(HAVE_TZNAME) && defined(HAVE_DAYLIGHT)
1728 *zone =
zone_str(tzname[daylight && tm.tm_isdst]);
1732 strftime(buf,
sizeof(buf),
"%Z", &tm);
1748 #if WIDEVALUE_IS_WIDER && SIZEOF_TIME_T < SIZEOF_INT64_T
1757 #if SIZEOF_TIME_T == SIZEOF_INT64_T
1760 if (~(time_t)0 <= 0) {
1770 timexv =
w2v(timew);
1796 result->
mon = tm.tm_mon + 1;
1797 result->
mday = tm.tm_mday;
1798 result->
hour = tm.tm_hour;
1799 result->
min = tm.tm_min;
1800 result->
sec = tm.tm_sec;
1802 result->
wday = tm.tm_wday;
1803 result->
yday = tm.tm_yday+1;
1804 result->
isdst = tm.tm_isdst;
1806 result->
zone = zone;
1820 result->
isdst = isdst;
1821 result->
zone = zone;
1833 #define GetTimeval(obj, tobj) ((tobj) = get_timeval(obj))
1834 #define GetNewTimeval(obj, tobj) ((tobj) = get_new_timeval(obj))
1836 #define IsTimeval(obj) rb_typeddata_is_kind_of((obj), &time_data_type)
1837 #define TIME_INIT_P(tobj) ((tobj)->gmt != -1)
1839 #define TIME_UTC_P(tobj) ((tobj)->gmt == 1)
1840 #define TIME_SET_UTC(tobj) ((tobj)->gmt = 1)
1842 #define TIME_LOCALTIME_P(tobj) ((tobj)->gmt == 0)
1843 #define TIME_SET_LOCALTIME(tobj) ((tobj)->gmt = 0)
1845 #define TIME_FIXOFF_P(tobj) ((tobj)->gmt == 2)
1846 #define TIME_SET_FIXOFF(tobj, off) \
1848 (tobj)->vtm.utc_offset = (off), \
1849 (tobj)->vtm.zone = NULL)
1851 #define TIME_COPY_GMT(tobj1, tobj2) \
1852 ((tobj1)->gmt = (tobj2)->gmt, \
1853 (tobj1)->vtm.utc_offset = (tobj2)->vtm.utc_offset, \
1854 (tobj1)->vtm.zone = (tobj2)->vtm.zone)
1857 #define MAKE_TM(time, tobj) \
1859 if ((tobj)->tm_got == 0) { \
1860 time_get_tm((time), (tobj)); \
1879 if (tobj)
xfree(tobj);
1998 #ifdef HAVE_CLOCK_GETTIME
1999 if (clock_gettime(CLOCK_REALTIME, &ts) == -1) {
2058 subsec =
neg(subsec);
2087 if (60 <= vtm->
sec) {
2098 if (60 <= vtm->
min) {
2105 if (vtm->
hour < 0) {
2109 if (24 <= vtm->
hour) {
2117 if (vtm->
mon == 1 && vtm->
mday == 1) {
2123 else if (vtm->
mday == 1) {
2125 leap_year_days_in_month :
2128 vtm->
mday = days_in_month[vtm->
mon-1];
2139 if (vtm->
mon == 12 && vtm->
mday == 31) {
2145 else if (vtm->
mday == (leap ? leap_year_days_in_month :
2146 common_year_days_in_month)[vtm->
mon-1]) {
2173 if (s[6] !=
':')
goto invalid_utc_offset;
2175 n += (s[7] * 10 + s[8] -
'0' * 11);
2177 if (s[0] !=
'+' && s[0] !=
'-')
goto invalid_utc_offset;
2179 if (s[3] !=
':')
goto invalid_utc_offset;
2183 goto invalid_utc_offset;
2185 n += (s[1] * 10 + s[2] -
'0' * 11) * 3600;
2186 n += (s[4] * 10 + s[5] -
'0' * 11) * 60;
2208 rb_scan_args(argc, argv,
"16", &v[0],&v[1],&v[2],&v[3],&v[4],&v[5],&v[6]);
2313 time_t tmp, sec = *secp;
2316 if (nsec >= 1000000000) {
2317 tmp = sec + nsec / 1000000000;
2319 if (sec > 0 && tmp < 0) {
2325 tmp = sec +
NDIV(nsec,1000000000);
2326 nsec =
NMOD(nsec,1000000000);
2327 if (sec < 0 && tmp > 0) {
2332 #ifndef NEGATIVE_TIME_T
2368 if (usec >= 1000000) {
2369 long sec2 = usec / 1000000;
2373 usec -= sec2 * 1000000;
2376 else if (usec <= 1000000) {
2377 long sec2 = usec / 1000000;
2381 usec -= sec2 * 1000000;
2414 const char *tstr = interval ?
"time interval" :
"time";
2417 #ifndef NEGATIVE_TIME_T
2421 switch (
TYPE(num)) {
2423 t.
tv_sec = NUM2TIMET(num);
2424 if (interval && t.
tv_sec < 0)
2438 if (t.
tv_nsec >= 1000000000) {
2443 else if ((t.
tv_nsec = (
int)(-d*1e9+0.5)) > 0) {
2455 t.
tv_sec = NUM2TIMET(num);
2456 if (interval && t.
tv_sec < 0)
2468 if (interval && t.
tv_sec < 0)
2598 "jan",
"feb",
"mar",
"apr",
"may",
"jun",
2599 "jul",
"aug",
"sep",
"oct",
"nov",
"dec",
2659 for (i=0; i<12; i++) {
2669 if (
'0' <= c && c <=
'9') {
2698 if ( vtm->
mon < 1 || vtm->
mon > 12
2701 || (vtm->
hour == 24 && (vtm->
min > 0 || vtm->
sec > 0))
2702 || vtm->
min < 0 || vtm->
min > 59
2703 || vtm->
sec < 0 || vtm->
sec > 60
2738 rb_scan_args(argc, argv,
"17", &v[0],&v[1],&v[2],&v[3],&v[4],&v[5],&v[6],&v[7]);
2765 if (!
NIL_P(v[6]) && argc == 7) {
2780 return ((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0);
2786 long tm_year = tm->tm_year;
2787 int tm_yday = tm->tm_mday;
2789 tm_yday += leap_year_yday_offset[tm->tm_mon];
2791 tm_yday += common_year_yday_offset[tm->tm_mon];
2799 return tm->tm_sec + tm->tm_min*60 + tm->tm_hour*3600 +
2803 DIV(tm_year-1,100) +
2804 DIV(tm_year+299,400))*86400;
2808 #define DEBUG_FIND_TIME_NUMGUESS
2809 #define DEBUG_GUESSRANGE
2812 #ifdef DEBUG_GUESSRANGE
2813 #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))
2815 #define DEBUG_REPORT_GUESSRANGE
2818 #ifdef DEBUG_FIND_TIME_NUMGUESS
2819 #define DEBUG_FIND_TIME_NUMGUESS_INC find_time_numguess++,
2820 static unsigned long long find_time_numguess;
2822 static VALUE find_time_numguess_getter(
void)
2824 return ULL2NUM(find_time_numguess);
2827 #define DEBUG_FIND_TIME_NUMGUESS_INC
2833 time_t guess, guess0, guess_lo, guess_hi;
2834 struct tm *tm, tm0, tm_lo, tm_hi;
2841 #define GUESS(p) (DEBUG_FIND_TIME_NUMGUESS_INC (utc_p ? gmtime_with_leapsecond((p), &result) : LOCALTIME((p), result)))
2846 find_dst = 0 < tptr->tm_isdst;
2848 #if defined(HAVE_MKTIME)
2850 if (!utc_p && (guess = mktime(&tm0)) != -1) {
2852 if (tm &&
tmcmp(tptr, tm) == 0) {
2859 if (tm0.tm_mon < 0) {
2866 else if (11 < tm0.tm_mon) {
2873 else if (tm0.tm_mday < 1) {
2880 leap_year_days_in_month :
2881 common_year_days_in_month)[tm0.tm_mon]) < tm0.tm_mday) {
2887 else if (tm0.tm_hour < 0) {
2892 else if (23 < tm0.tm_hour) {
2897 else if (tm0.tm_min < 0) {
2901 else if (59 < tm0.tm_min) {
2905 else if (tm0.tm_sec < 0) {
2908 else if (60 < tm0.tm_sec) {
2916 d =
tmcmp(tptr, tm);
2917 if (d == 0) {
goto found; }
2920 guess -= 24 * 60 * 60;
2924 guess += 24 * 60 * 60;
2927 if (guess_lo < guess && guess < guess_hi && (tm =
GUESS(&guess)) !=
NULL) {
2928 d =
tmcmp(tptr, tm);
2929 if (d == 0) {
goto found; }
2938 tm =
GUESS(&guess_lo);
2939 if (!tm)
goto error;
2940 d =
tmcmp(tptr, tm);
2941 if (d < 0)
goto out_of_range;
2942 if (d == 0) { guess = guess_lo;
goto found; }
2945 tm =
GUESS(&guess_hi);
2946 if (!tm)
goto error;
2947 d =
tmcmp(tptr, tm);
2948 if (d > 0)
goto out_of_range;
2949 if (d == 0) { guess = guess_hi;
goto found; }
2956 while (guess_lo + 1 < guess_hi) {
2959 guess = guess_lo / 2 + guess_hi / 2;
2960 if (guess <= guess_lo)
2961 guess = guess_lo + 1;
2962 else if (guess >= guess_hi)
2963 guess = guess_hi - 1;
2969 guess = guess_hi - (guess0_hi - guess0);
2970 if (guess == guess_hi)
2974 else if (status == 2) {
2976 guess = guess_lo + (guess0 - guess0_lo);
2977 if (guess == guess_lo)
2981 if (guess <= guess_lo || guess_hi <= guess) {
2983 #ifdef DEBUG_GUESSRANGE
2984 if (guess <= guess_lo) fprintf(stderr,
"too small guess: %ld <= %ld\n", guess, guess_lo);
2985 if (guess_hi <= guess) fprintf(stderr,
"too big guess: %ld <= %ld\n", guess_hi, guess);
2992 if (!tm)
goto error;
2994 d =
tmcmp(tptr, tm);
3012 guess2 = guess - 2 * 60 * 60;
3015 if (tptr->tm_hour != (tm->tm_hour + 2) % 24 ||
3016 tptr->tm_min != tm->tm_min ||
3017 tptr->tm_sec != tm->tm_sec) {
3018 guess2 -= (tm->tm_hour - tptr->tm_hour) * 60 * 60 +
3019 (tm->tm_min - tptr->tm_min) * 60 +
3020 (tm->tm_sec - tptr->tm_sec);
3021 if (tptr->tm_mday != tm->tm_mday)
3022 guess2 += 24 * 60 * 60;
3023 if (guess != guess2) {
3025 if (tm &&
tmcmp(tptr, tm) == 0) {
3037 guess2 = guess + 2 * 60 * 60;
3040 if ((tptr->tm_hour + 2) % 24 != tm->tm_hour ||
3041 tptr->tm_min != tm->tm_min ||
3042 tptr->tm_sec != tm->tm_sec) {
3043 guess2 -= (tm->tm_hour - tptr->tm_hour) * 60 * 60 +
3044 (tm->tm_min - tptr->tm_min) * 60 +
3045 (tm->tm_sec - tptr->tm_sec);
3046 if (tptr->tm_mday != tm->tm_mday)
3047 guess2 -= 24 * 60 * 60;
3048 if (guess != guess2) {
3050 if (tm &&
tmcmp(tptr, tm) == 0) {
3075 tptr_tm_yday =
calc_tm_yday(tptr->tm_year, tptr->tm_mon, tptr->tm_mday);
3078 ((tptr->tm_year - tm_lo.tm_year) * 365 +
3079 ((tptr->tm_year-69)/4) -
3080 ((tptr->tm_year-1)/100) +
3081 ((tptr->tm_year+299)/400) -
3082 ((tm_lo.tm_year-69)/4) +
3083 ((tm_lo.tm_year-1)/100) -
3084 ((tm_lo.tm_year+299)/400) +
3086 tm_lo.tm_yday) * 86400 +
3087 (tptr->tm_hour - tm_lo.tm_hour) * 3600 +
3088 (tptr->tm_min - tm_lo.tm_min) * 60 +
3089 (tptr->tm_sec - (tm_lo.tm_sec == 60 ? 59 : tm_lo.tm_sec));
3094 return "time out of range";
3097 return "gmtime/localtime error";
3105 else if (a->
mon != b->
mon)
3106 return a->
mon < b->
mon ? -1 : 1;
3111 else if (a->
min != b->
min)
3112 return a->
min < b->
min ? -1 : 1;
3113 else if (a->
sec != b->
sec)
3114 return a->
sec < b->
sec ? -1 : 1;
3124 if (a->tm_year != b->tm_year)
3125 return a->tm_year < b->tm_year ? -1 : 1;
3126 else if (a->tm_mon != b->tm_mon)
3127 return a->tm_mon < b->tm_mon ? -1 : 1;
3128 else if (a->tm_mday != b->tm_mday)
3129 return a->tm_mday < b->tm_mday ? -1 : 1;
3130 else if (a->tm_hour != b->tm_hour)
3131 return a->tm_hour < b->tm_hour ? -1 : 1;
3132 else if (a->tm_min != b->tm_min)
3133 return a->tm_min < b->tm_min ? -1 : 1;
3134 else if (a->tm_sec != b->tm_sec)
3135 return a->tm_sec < b->tm_sec ? -1 : 1;
3418 if (n == 0)
return INT2FIX(0);
3854 rb_warn(
"Time#succ is obsolete; use time + 1");
3862 #define time_succ rb_time_succ
3904 VALUE ndigits,
v, a, b, den;
4094 #define wday_p(n) {\
4095 struct time_object *tobj;\
4096 GetTimeval(time, tobj);\
4097 MAKE_TM(time, tobj);\
4098 return (tobj->vtm.wday == (n)) ? Qtrue : Qfalse;\
4365 #define SMALLBUF 100
4370 size_t size, len, flen;
4387 if (len != 0 || (**buf ==
'\0' &&
errno != ERANGE))
return len;
4388 for (size=1024; ; size*=2) {
4394 len =
rb_strftime(*buf, size, format, enc, vtm, timev, gmt);
4404 if (size >= 1024 * flen) {
4425 if (buf != buffer)
xfree(buf);
4634 rb_warning(
"strftime called with empty format string");
4636 else if (memchr(fmt,
'\0', len)) {
4638 const char *
p = fmt, *pe = fmt + len;
4646 if (buf != buffer) {
4650 for (fmt = p; p < pe && !*
p; ++
p);
4660 if (buf != buffer)
xfree(buf);
4685 if (year < 1900 || 1900+0xffff < year)
4712 for (i=0; i<4; i++) {
4713 buf[
i] = (
unsigned char)p;
4716 for (i=4; i<8; i++) {
4717 buf[
i] = (
unsigned char)s;
4742 int len = (int)
sizeof(buf);
4743 buf[1] = (char)((nsec % 10) << 4);
4745 buf[0] = (char)(nsec % 10);
4747 buf[0] |= (char)((nsec % 10) << 4);
4789 VALUE submicro, nano_num, nano_den, offset,
zone;
4795 #define get_attr(attr, iffound) \
4796 attr = rb_attr_get(str, id_##attr); \
4797 if (!NIL_P(attr)) { \
4800 st_delete(rb_generic_ivar_table(str), &data, 0); \
4820 for (i=0; i<4; i++) {
4823 for (i=4; i<8; i++) {
4824 s |= buf[
i]<<(8*(i-4));
4827 if ((p & (1UL<<31)) == 0) {
4837 gmt = (int)((p >> 30) & 0x1);
4839 vtm.
year =
INT2FIX(((
int)(p >> 14) & 0xffff) + 1900);
4840 vtm.
mon = ((int)(p >> 10) & 0xf) + 1;
4841 vtm.
mday = (int)(p >> 5) & 0x1f;
4842 vtm.
hour = (int) p & 0x1f;
4843 vtm.
min = (int)(s >> 26) & 0x3f;
4844 vtm.
sec = (int)(s >> 20) & 0x3f;
4850 usec = (long)(s & 0xfffff);
4855 if (nano_num !=
Qnil) {
4859 else if (submicro !=
Qnil) {
4867 if (10 <= (digit = ptr[0] >> 4))
goto end_submicro;
4868 nsec += digit * 100;
4869 if (10 <= (digit = ptr[0] & 0xf))
goto end_submicro;
4873 if (10 <= (digit = ptr[1] >> 4))
goto end_submicro;
4885 tobj->
timew = timew;
4889 else if (!
NIL_P(offset)) {
5004 #define rb_intern(str) rb_intern_const(str)
5105 #ifdef DEBUG_FIND_TIME_NUMGUESS
static const rb_data_type_t time_data_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)
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)
void rb_define_virtual_variable(const char *, VALUE(*)(ANYARGS), void(*)(ANYARGS))
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)
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)
VALUE rb_str_cat(VALUE, const char *, long)
static void split_second(wideval_t timew, wideval_t *timew_p, VALUE *subsecx_p)
static VALUE obj2vint(VALUE obj)
static VALUE time_minus(VALUE time1, VALUE time2)
static VALUE small_vtm_sub(struct vtm *vtm1, struct vtm *vtm2)
#define OBJ_INIT_COPY(obj, orig)
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_utc_offset _((VALUE))
#define TypedData_Get_Struct(obj, type, data_type, sval)
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)
struct timeval rb_time_interval(VALUE num)
void rb_define_private_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
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)
#define rb_check_trusted(obj)
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
static const int common_year_days_in_month[]
VALUE rb_time_succ(VALUE time)
#define TYPEOF_TIMEVAL_TV_USEC
static VALUE time_init(int argc, VALUE *argv, VALUE time)
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)
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
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)
void rb_gc_mark(VALUE ptr)
static VALUE time_usec(VALUE time)
static int long_mul(long x, long y, long *z)
static int compat_leap_month_table[7]
int st_update(st_table *table, st_data_t key, st_update_callback_func *func, st_data_t arg)
#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)
VALUE rb_check_to_integer(VALUE, const char *)
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)
const char * rb_obj_classname(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)
VALUE rb_obj_untaint(VALUE)
static struct tm * rb_gmtime_r2(const time_t *t, struct tm *result)
static time_t wv2timet(wideval_t w)
VALUE rb_singleton_class(VALUE obj)
Returns the singleton class of obj.
static VALUE time_wday(VALUE time)
#define RB_TYPE_P(obj, type)
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
VALUE rb_rescue(VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*r_proc)(ANYARGS), VALUE data2)
#define GetNewTimeval(obj, tobj)
static wideval_t wmod(wideval_t wx, wideval_t wy)
VALUE rb_class_new_instance(int, VALUE *, VALUE)
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)
static VALUE time_load(VALUE klass, VALUE str)
RUBY_EXTERN VALUE rb_cObject
#define get_attr(attr, iffound)
VALUE rb_time_new(time_t sec, long usec)
#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)
static VALUE time_saturday(VALUE time)
#define TIME_FIXOFF_P(tobj)
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)
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)
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)
#define MEMCPY(p1, p2, type, n)
static VALUE validate_utc_offset(VALUE utc_offset)
static struct tm * rb_gmtime_r(const time_t *tp, struct tm *result)
void rb_num_zerodiv(void)
static VALUE guess_local_offset(struct vtm *vtm_utc, int *isdst_ret, const char **zone_ret)
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)
VALUE rb_big_minus(VALUE x, VALUE y)
static VALUE time_to_s(VALUE time)
VALUE rb_locale_str_new_cstr(const char *)
static VALUE time_to_f(VALUE time)
static const int leap_year_yday_offset[]
VALUE rb_check_funcall(VALUE, ID, int, VALUE *)
size_t rb_strftime(char *s, size_t maxsize, const char *format, rb_encoding *enc, const struct vtm *vtm, VALUE timev, int gmt)
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,...)
VALUE rb_ivar_set(VALUE, ID, VALUE)
#define TIME_COPY_GMT(tobj1, tobj2)
static void time_free(void *tobj)
unsigned char buf[MIME_BUF_SIZE]
static wideval_t rb_time_magnify(wideval_t w)
rb_encoding * rb_usascii_encoding(void)
static VALUE time_fixoff(VALUE)
static VALUE num_exact(VALUE v)
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
#define rb_enc_str_asciicompat_p(str)
static struct timespec time_timespec(VALUE num, int interval)
static VALUE sub(VALUE x, VALUE y)
VALUE rb_time_nano_new(time_t sec, long nsec)
static int timew_out_of_timet_range(wideval_t timew)
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 VALUE validate_zone_name(VALUE zone_name)
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)
int rb_respond_to(VALUE, ID)
static const int common_year_yday_offset[]
static struct timeval time_timeval(VALUE num, int interval)
#define StringValueCStr(v)
static VALUE time_strftime(VALUE time, VALUE format)
static wideval_t timegmw_noleapsecond(struct vtm *vtm)
static VALUE time_hour(VALUE time)
static time_t known_leap_seconds_limit
VALUE rb_equal(VALUE, VALUE)
rb_encoding * rb_enc_get(VALUE obj)
#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)
static VALUE time_s_mkutc(int argc, VALUE *argv, VALUE klass)
static wideval_t timespec2timew(struct timespec *ts)
#define MAKE_TM(time, tobj)
VALUE rb_check_string_type(VALUE)
static struct tm * gmtime_with_leapsecond(const time_t *timep, struct tm *result)
struct timespec rb_time_timespec(VALUE time)
static void wmuldivmod(wideval_t wx, wideval_t wy, wideval_t wz, wideval_t *wq, wideval_t *wr)
static int compat_common_month_table[12][7]
static void time_overflow_p(time_t *secp, long *nsecp)
SIGNED_VALUE SIGNED_WIDEVALUE
#define TypedData_Make_Struct(klass, type, data_type, sval)
static void init_leap_second_info(void)
VALUE rb_enc_str_new(const char *, long, rb_encoding *)
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)
#define StringValuePtr(v)
static VALUE time_zone(VALUE time)
VALUE rb_str_new_frozen(VALUE)
#define STRCASECMP(s1, s2)
void rb_warning(const char *fmt,...)
static wideval_t timet2wv(time_t t)
#define rb_check_frozen(obj)
static void time_modify(VALUE time)
static VALUE time_s_mktime(int argc, VALUE *argv, VALUE klass)
void rb_copy_generic_ivar(VALUE, VALUE)
static int zone_str_update(st_data_t *key, st_data_t *value, st_data_t arg, int existing)
#define RBIGNUM_NEGATIVE_P(b)
static VALUE time_year(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)
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 time)
VALUE rb_str_new(const char *, long)
VALUE rb_obj_class(VALUE)
static wideval_t timegmw(struct vtm *vtm)
VALUE rb_time_num_new(VALUE timev, VALUE off)
static wideval_t wquo(wideval_t wx, wideval_t wy)