12 #define _DEFAULT_SOURCE 15 #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)) 43 #define VTM_WDAY_INITVAL (7) 44 #define VTM_ISDST_INITVAL (3) 45 #define TO_GMT_INITVAL (3) 60 if ((
long)x < (
long)y)
62 if ((
long)x > (
long)y)
69 #define ne(x,y) (!eq((x),(y))) 70 #define lt(x,y) (cmp((x),(y)) < 0) 71 #define gt(x,y) (cmp((x),(y)) > 0) 72 #define le(x,y) (cmp((x),(y)) <= 0) 73 #define ge(x,y) (cmp((x),(y)) >= 0) 106 #define div(x,y) (rb_funcall((x), id_div, 1, (y))) 119 #define neg(x) (sub(INT2FIX(0), (x))) 144 #define mulquo(x,y,z) (((y) == (z)) ? (x) : quo(mul((x),(y)),(z))) 168 # define INT64toNUM(x) LONG2NUM(x) 169 #elif defined(HAVE_LONG_LONG) && SIZEOF_LONG_LONG == 8 170 # define INT64toNUM(x) LL2NUM(x) 173 #if defined(HAVE_UINT64_T) && SIZEOF_LONG*2 <= SIZEOF_UINT64_T 178 # define WIDEVALUE_IS_WIDER 1 179 # define UWIDEINT_MAX UINT64_MAX 180 # define WIDEINT_MAX INT64_MAX 181 # define WIDEINT_MIN INT64_MIN 182 # define FIXWINT_P(tv) ((tv) & 1) 183 # define FIXWVtoINT64(tv) RSHIFT((SIGNED_WIDEVALUE)(tv), 1) 184 # define INT64toFIXWV(wi) ((WIDEVALUE)((SIGNED_WIDEVALUE)(wi) << 1 | FIXNUM_FLAG)) 185 # define FIXWV_MAX (((int64_t)1 << 62) - 1) 186 # define FIXWV_MIN (-((int64_t)1 << 62)) 187 # define FIXWVABLE(wi) (POSFIXWVABLE(wi) && NEGFIXWVABLE(wi)) 188 # define WINT2FIXWV(i) WIDEVAL_WRAP(INT64toFIXWV(i)) 189 # define FIXWV2WINT(w) FIXWVtoINT64(WIDEVAL_GET(w)) 195 # define WIDEVALUE_IS_WIDER 0 196 # define UWIDEINT_MAX ULONG_MAX 197 # define WIDEINT_MAX LONG_MAX 198 # define WIDEINT_MIN LONG_MIN 199 # define FIXWINT_P(v) FIXNUM_P(v) 200 # define FIXWV_MAX FIXNUM_MAX 201 # define FIXWV_MIN FIXNUM_MIN 202 # define FIXWVABLE(i) FIXABLE(i) 203 # define WINT2FIXWV(i) WIDEVAL_WRAP(LONG2FIX(i)) 204 # define FIXWV2WINT(w) FIX2LONG(WIDEVAL_GET(w)) 207 #define POSFIXWVABLE(wi) ((wi) < FIXWV_MAX+1) 208 #define NEGFIXWVABLE(wi) ((wi) >= FIXWV_MIN) 209 #define FIXWV_P(w) FIXWINT_P(WIDEVAL_GET(w)) 210 #define MUL_OVERFLOW_FIXWV_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, FIXWV_MIN, FIXWV_MAX) 213 #ifdef STRUCT_WIDEVAL 219 # define WIDEVAL_GET(w) ((w).value) 222 # define WIDEVAL_WRAP(v) (v) 223 # define WIDEVAL_GET(w) (w) 226 #if WIDEVALUE_IS_WIDER 235 # define WINT2WV(wi) wint2wv(wi) 237 # define WINT2WV(wi) WIDEVAL_WRAP(LONG2NUM(wi)) 243 #if WIDEVALUE_IS_WIDER 252 #if WIDEVALUE_IS_WIDER 262 else if (sign == -1) {
266 else if (sign == +1) {
282 #if WIDEVALUE_IS_WIDER 288 return v2w_bignum(v);
297 #if WIDEVALUE_IS_WIDER 311 #if WIDEVALUE_IS_WIDER 328 #define wne(x,y) (!weq((x),(y))) 329 #define wlt(x,y) (wcmp((x),(y)) < 0) 330 #define wgt(x,y) (wcmp((x),(y)) > 0) 331 #define wle(x,y) (wcmp((x),(y)) <= 0) 332 #define wge(x,y) (wcmp((x),(y)) >= 0) 338 #if WIDEVALUE_IS_WIDER 354 #if WIDEVALUE_IS_WIDER 369 #if WIDEVALUE_IS_WIDER 381 #if WIDEVALUE_IS_WIDER 396 #define wmulquo(x,y,z) ((WIDEVAL_GET(y) == WIDEVAL_GET(z)) ? (x) : wquo(wmul((x),(y)),(z))) 397 #define wmulquoll(x,y,z) (((y) == (z)) ? (x) : wquo(wmul((x),WINT2WV(y)),WINT2WV(z))) 399 #if WIDEVALUE_IS_WIDER 426 if (d > 0 ? r < 0 : r > 0) {
442 #if WIDEVALUE_IS_WIDER 443 if (wdivmod0(wn, wd, wq, wr))
return;
464 #if WIDEVALUE_IS_WIDER 466 if (wdivmod0(wx, wy, &q, &dmy))
return q;
474 #if WIDEVALUE_IS_WIDER 476 if (wdivmod0(wx, wy, &dmy, &r))
return r;
547 #if WIDEVALUE_IS_WIDER 579 #if WIDEVALUE_IS_WIDER 580 if (TIMET_MIN == 0) {
593 return v2w(TIMET2NUM(t));
595 #define TIMET2WV(t) timet2wv(t) 600 #if WIDEVALUE_IS_WIDER 603 if (TIMET_MIN == 0) {
610 if (wi < TIMET_MIN || TIMET_MAX < wi)
616 return NUM2TIMET(
w2v(w));
618 #define WV2TIMET(t) wv2timet(t) 637 static int tmcmp(
struct tm *a,
struct tm *b);
638 static int vtmcmp(
struct vtm *a,
struct vtm *b);
639 static const char *
find_time_t(
struct tm *tptr,
int utc_p, time_t *tp);
644 #define leap_year_v_p(y) leap_year_p(NUM2LONG(mod((y), INT2FIX(400)))) 649 #if defined __APPLE__ && defined __LP64__ 650 if (*t != (time_t)(
int)*t)
return NULL;
656 struct tm *tmp = localtime(t);
657 if (tmp) *result = *tmp;
660 #if defined(HAVE_MKTIME) && defined(LOCALTIME_OVERFLOW_PROBLEM) 667 # if defined(HAVE_STRUCT_TM_TM_GMTOFF) 668 gmtoff1 = result->tm_gmtoff;
669 gmtoff2 = tmp.tm_gmtoff;
671 if (*t + gmtoff1 != t2 + gmtoff2)
677 #define LOCALTIME(tm, result) (tzset(),rb_localtime_r((tm), &(result))) 679 #ifndef HAVE_STRUCT_TM_TM_GMTOFF 686 struct tm *tmp = gmtime(t);
687 if (tmp) *result = *tmp;
689 #if defined(HAVE_TIMEGM) && defined(LOCALTIME_OVERFLOW_PROBLEM) 690 if (result && *t != timegm(result)) {
696 # define GMTIME(tm, result) rb_gmtime_r((tm), &(result)) 704 -1 + 31 + 28 + 31 + 30,
705 -1 + 31 + 28 + 31 + 30 + 31,
706 -1 + 31 + 28 + 31 + 30 + 31 + 30,
707 -1 + 31 + 28 + 31 + 30 + 31 + 30 + 31,
708 -1 + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31,
709 -1 + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30,
710 -1 + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31,
711 -1 + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30
719 -1 + 31 + 29 + 31 + 30,
720 -1 + 31 + 29 + 31 + 30 + 31,
721 -1 + 31 + 29 + 31 + 30 + 31 + 30,
722 -1 + 31 + 29 + 31 + 30 + 31 + 30 + 31,
723 -1 + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31,
724 -1 + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30,
725 -1 + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31,
726 -1 + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30
731 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
734 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
740 int tm_year_mod400 = (int)
MOD(tm_year, 400);
741 int tm_yday = tm_mday;
744 tm_yday += leap_year_yday_offset[tm_mon];
746 tm_yday += common_year_yday_offset[tm_mon];
767 yday =
calc_tm_yday(year_mod400, vtm->mon-1, vtm->mday);
780 +
DIV(year_mod400 - 69, 4)
781 -
DIV(year_mod400 - 1, 100)
782 + (year_mod400 + 299) / 400;
787 wret =
wadd(wret,
v2w(vtm->subsecx));
797 const char *s = (
const char *)*key;
798 const char **ret = (
const char **)arg;
801 *ret = (
const char *)*value;
824 const int *yday_offset;
838 vtm->wday = (wday + 4) % 7;
841 vtm->sec = n % 60; n = n / 60;
842 vtm->min = n % 60; n = n / 60;
859 if (30*365+7+31+29-1 <= n) {
873 x = n / (365*100 + 24);
874 n = n % (365*100 + 24);
876 if (30*365+7+31+29-1 <= n) {
889 if (365*2+31+29-1 <= n) {
912 for (i = 0; i < 12; i++) {
913 if (yday_offset[i] < n) {
915 vtm->mday = n - yday_offset[i];
928 #if defined(HAVE_STRUCT_TM_TM_GMTOFF) 932 int gmtoff_sec, gmtoff_min, gmtoff_hour, gmtoff_day;
939 if (t->tm_gmtoff < 0) {
941 gmtoff = -t->tm_gmtoff;
945 gmtoff = t->tm_gmtoff;
947 gmtoff_sec = (int)(gmtoff % 60);
948 gmtoff = gmtoff / 60;
949 gmtoff_min = (int)(gmtoff % 60);
950 gmtoff = gmtoff / 60;
951 gmtoff_hour = (int)gmtoff;
962 result->tm_sec += gmtoff_sec;
963 if (result->tm_sec < 0) {
964 result->tm_sec += 60;
967 if (60 <= result->tm_sec) {
968 result->tm_sec -= 60;
973 result->tm_min += gmtoff_min;
974 if (result->tm_min < 0) {
975 result->tm_min += 60;
978 if (60 <= result->tm_min) {
979 result->tm_min -= 60;
984 result->tm_hour += gmtoff_hour;
985 if (result->tm_hour < 0) {
986 result->tm_hour += 24;
989 if (24 <= result->tm_hour) {
990 result->tm_hour -= 24;
996 if (gmtoff_day < 0) {
997 if (result->tm_yday == 0) {
998 result->tm_mday = 31;
1001 result->tm_yday =
leap_year_p(result->tm_year + 1900) ? 365 : 364;
1003 else if (result->tm_mday == 1) {
1004 const int *days_in_month =
leap_year_p(result->tm_year + 1900) ?
1008 result->tm_mday = days_in_month[result->tm_mon];
1015 result->tm_wday = (result->tm_wday + 6) % 7;
1019 if (result->tm_yday == (leap ? 365 : 364)) {
1022 result->tm_mday = 1;
1023 result->tm_yday = 0;
1025 else if (result->tm_mday == (leap ? leap_year_days_in_month :
1026 common_year_days_in_month)[result->tm_mon]) {
1028 result->tm_mday = 1;
1035 result->tm_wday = (result->tm_wday + 1) % 7;
1038 result->tm_isdst = 0;
1039 result->tm_gmtoff = 0;
1040 #if defined(HAVE_TM_ZONE) 1041 result->tm_zone = (
char *)
"UTC";
1045 return GMTIME(timep, *result);
1061 if (this_year == 0) {
1070 this_year = tm->tm_year;
1072 if (TIMET_MAX - now < (time_t)(366*86400))
1073 known_leap_seconds_limit = TIMET_MAX;
1075 known_leap_seconds_limit = now + (time_t)(366*86400);
1080 vtm.year =
LONG2NUM(result.tm_year + 1900);
1081 vtm.mon = result.tm_mon + 1;
1082 vtm.mday = result.tm_mday;
1083 vtm.hour = result.tm_hour;
1084 vtm.min = result.tm_min;
1085 vtm.sec = result.tm_sec;
1117 tm.tm_mon = vtm->mon - 1;
1118 tm.tm_mday = vtm->mday;
1119 tm.tm_hour = vtm->hour;
1120 tm.tm_min = vtm->min;
1121 tm.tm_sec = vtm->sec;
1157 result->year =
LONG2NUM((
long)tm.tm_year + 1900);
1158 result->mon = tm.tm_mon + 1;
1159 result->mday = tm.tm_mday;
1160 result->hour = tm.tm_hour;
1161 result->min = tm.tm_min;
1162 result->sec = tm.tm_sec;
1163 result->subsecx = subsecx;
1164 result->utc_offset =
INT2FIX(0);
1165 result->wday = tm.tm_wday;
1166 result->yday = tm.tm_yday+1;
1167 result->isdst = tm.tm_isdst;
1168 result->zone =
"UTC";
1210 { 2034, 2035, 2036, 2031, 2032, 2027, 2033 },
1211 { 2026, 2027, 2033, 2034, 2035, 2030, 2031 },
1212 { 2026, 2032, 2033, 2034, 2035, 2030, 2036 },
1213 { 2035, 2030, 2036, 2026, 2032, 2033, 2034 },
1214 { 2033, 2034, 2035, 2030, 2036, 2026, 2032 },
1215 { 2036, 2026, 2032, 2033, 2034, 2035, 2030 },
1216 { 2035, 2030, 2036, 2026, 2032, 2033, 2034 },
1217 { 2032, 2033, 2034, 2035, 2030, 2036, 2026 },
1218 { 2030, 2036, 2026, 2032, 2033, 2034, 2035 },
1219 { 2034, 2035, 2030, 2036, 2026, 2032, 2033 },
1220 { 2026, 2032, 2033, 2034, 2035, 2030, 2036 },
1221 { 2030, 2036, 2026, 2032, 2033, 2034, 2035 },
1251 2032, 2016, 2028, 2012, 2024, 2036, 2020,
1260 a = (14 - month) / 12;
1261 y = year + 4800 - a;
1262 m = month + 12 * a - 3;
1263 wday = day + (153*m+2)/5 + 365*y + y/4 - y/100 + y/400 + 2;
1286 # if defined(NEGATIVE_TIME_T) 1287 # if SIZEOF_TIME_T <= 4 1289 # define THE_TIME_OLD_ENOUGH ((time_t)0x80000000) 1293 # define THE_TIME_OLD_ENOUGH ((time_t)(1600-1970)*366*24*60*60) 1297 isdst = tm.tm_isdst;
1304 isdst = tm.tm_isdst;
1322 vtm2.year =
INT2FIX(compat_leap_month_table[wday]);
1324 vtm2.year =
INT2FIX(compat_common_month_table[vtm_utc->mon-1][wday]);
1327 t = NUM2TIMET(timev);
1331 *isdst_ret = tm.tm_isdst;
1339 static time_t now = 0;
1340 static long now_gmtoff = 0;
1341 static const char *now_zone =
"UTC";
1347 *isdst_ret = tm.tm_isdst;
1349 *zone_ret = now_zone;
1359 off = vtm1->sec - vtm2->sec;
1360 off += (vtm1->min - vtm2->min) * 60;
1361 off += (vtm1->hour - vtm2->hour) * 3600;
1362 if (
ne(vtm1->year, vtm2->year))
1363 off +=
lt(vtm1->year, vtm2->year) ? -24*3600 : 24*3600;
1364 else if (vtm1->mon != vtm2->mon)
1365 off += vtm1->mon < vtm2->mon ? -24*3600 : 24*3600;
1366 else if (vtm1->mday != vtm2->mday)
1367 off += vtm1->mday < vtm2->mday ? -24*3600 : 24*3600;
1379 struct vtm vtm1, vtm2;
1383 long l =
FIX2LONG(vtm->year) - 1900;
1384 if (l < INT_MIN || INT_MAX < l)
1386 tm.tm_year = (int)l;
1395 tm.tm_mon = vtm->mon-1;
1396 tm.tm_mday = vtm->mday;
1397 tm.tm_hour = vtm->hour;
1398 tm.tm_min = vtm->min;
1399 tm.tm_sec = vtm->sec;
1435 if (
weq(timew1, timew2))
1440 if (vtm->hour != vtm1.hour || vtm->min != vtm1.min || vtm->sec != vtm1.sec)
1445 if (vtm->hour != vtm2.hour || vtm->min != vtm2.min || vtm->sec != vtm2.sec)
1449 return lt(vtm1.utc_offset, vtm2.utc_offset) ? timew2 : timew1;
1451 return lt(vtm1.utc_offset, vtm2.utc_offset) ? timew1 : timew2;
1460 #if defined(HAVE_STRUCT_TM_TM_GMTOFF) 1461 *gmtoff = tm.tm_gmtoff;
1470 if (l->tm_year != u->tm_year)
1471 off = l->tm_year < u->tm_year ? -1 : 1;
1472 else if (l->tm_mon != u->tm_mon)
1473 off = l->tm_mon < u->tm_mon ? -1 : 1;
1474 else if (l->tm_mday != u->tm_mday)
1475 off = l->tm_mday < u->tm_mday ? -1 : 1;
1478 off = off * 24 + l->tm_hour - u->tm_hour;
1479 off = off * 60 + l->tm_min - u->tm_min;
1480 off = off * 60 + l->tm_sec - u->tm_sec;
1485 #if defined(HAVE_TM_ZONE) 1489 *zone =
zone_str(
"(NO-TIMEZONE-ABBREVIATION)");
1490 #elif defined(HAVE_TZNAME) && defined(HAVE_DAYLIGHT) 1491 # if RUBY_MSVCRT_VERSION >= 140 1492 # define tzname _tzname 1493 # define daylight _daylight 1496 *zone =
zone_str(tzname[daylight && tm.tm_isdst]);
1500 strftime(buf,
sizeof(buf),
"%Z", &tm);
1516 #if WIDEVALUE_IS_WIDER && SIZEOF_TIME_T < SIZEOF_INT64_T 1525 #if SIZEOF_TIME_T == SIZEOF_INT64_T 1528 if (~(time_t)0 <= 0) {
1538 timexv =
w2v(timew);
1548 VALUE subsecx, offset;
1563 result->year =
LONG2NUM((
long)tm.tm_year + 1900);
1564 result->mon = tm.tm_mon + 1;
1565 result->mday = tm.tm_mday;
1566 result->hour = tm.tm_hour;
1567 result->min = tm.tm_min;
1568 result->sec = tm.tm_sec;
1569 result->subsecx = subsecx;
1570 result->wday = tm.tm_wday;
1571 result->yday = tm.tm_yday+1;
1572 result->isdst = tm.tm_isdst;
1573 result->utc_offset =
LONG2NUM(gmtoff);
1574 result->zone = zone;
1587 result->utc_offset = offset;
1588 result->isdst = isdst;
1589 result->zone = zone;
1601 #define GetTimeval(obj, tobj) ((tobj) = get_timeval(obj)) 1602 #define GetNewTimeval(obj, tobj) ((tobj) = get_new_timeval(obj)) 1604 #define IsTimeval(obj) rb_typeddata_is_kind_of((obj), &time_data_type) 1605 #define TIME_INIT_P(tobj) ((tobj)->gmt != TO_GMT_INITVAL) 1607 #define TIME_UTC_P(tobj) ((tobj)->gmt == 1) 1608 #define TIME_SET_UTC(tobj) ((tobj)->gmt = 1) 1610 #define TIME_LOCALTIME_P(tobj) ((tobj)->gmt == 0) 1611 #define TIME_SET_LOCALTIME(tobj) ((tobj)->gmt = 0) 1613 #define TIME_FIXOFF_P(tobj) ((tobj)->gmt == 2) 1614 #define TIME_SET_FIXOFF(tobj, off) \ 1616 (tobj)->vtm.utc_offset = (off), \ 1617 (tobj)->vtm.zone = NULL) 1619 #define TIME_COPY_GMT(tobj1, tobj2) \ 1620 ((tobj1)->gmt = (tobj2)->gmt, \ 1621 (tobj1)->vtm.utc_offset = (tobj2)->vtm.utc_offset, \ 1622 (tobj1)->vtm.zone = (tobj2)->vtm.zone) 1625 #define MAKE_TM(time, tobj) \ 1627 if ((tobj)->tm_got == 0) { \ 1628 time_get_tm((time), (tobj)); \ 1635 struct time_object *tobj = ptr;
1646 return sizeof(
struct time_object);
1659 struct time_object *tobj;
1669 static struct time_object *
1672 struct time_object *tobj;
1680 static struct time_object *
1683 struct time_object *tobj;
1745 #ifdef HAVE_CLOCK_GETTIME 1764 struct time_object *tobj;
1781 struct time_object *tobj;
1801 vtm->utc_offset =
sub(vtm->utc_offset, off);
1819 subsec =
neg(subsec);
1881 if (vtm->mon == 1 && vtm->mday == 1) {
1887 else if (vtm->mday == 1) {
1892 vtm->mday = days_in_month[vtm->mon-1];
1899 vtm->wday = (vtm->wday + 6) % 7;
1903 if (vtm->mon == 12 && vtm->mday == 31) {
1909 else if (vtm->mday == (leap ? leap_year_days_in_month :
1910 common_year_days_in_month)[vtm->mon-1]) {
1919 vtm->wday = (vtm->wday + 1) % 7;
1937 if (s[6] !=
':')
goto invalid_utc_offset;
1939 n += (s[7] * 10 + s[8] -
'0' * 11);
1941 if (s[0] !=
'+' && s[0] !=
'-')
goto invalid_utc_offset;
1943 if (s[3] !=
':')
goto invalid_utc_offset;
1945 if (s[4] >
'5')
goto invalid_utc_offset;
1948 goto invalid_utc_offset;
1950 n += (s[1] * 10 + s[2] -
'0' * 11) * 3600;
1951 n += (s[4] * 10 + s[5] -
'0' * 11) * 60;
1966 struct time_object *tobj;
1973 rb_scan_args(argc, argv,
"16", &v[0],&v[1],&v[2],&v[3],&v[4],&v[5],&v[6]);
1989 vtm.utc_offset =
Qnil;
2008 if (!
NIL_P(vtm.utc_offset)) {
2009 VALUE off = vtm.utc_offset;
2011 vtm.utc_offset =
Qnil;
2082 if (nsec >= 1000000000) {
2083 sec2 = nsec / 1000000000;
2084 if (TIMET_MAX - sec2 < sec) {
2087 nsec -= sec2 * 1000000000;
2090 else if (nsec < 0) {
2091 sec2 =
NDIV(nsec,1000000000);
2092 if (sec < TIMET_MIN - sec2) {
2095 nsec -= sec2 * 1000000000;
2098 #ifndef NEGATIVE_TIME_T 2120 struct time_object *tobj;
2124 tobj->timew = timew;
2134 if (usec >= 1000000) {
2135 long sec2 = usec / 1000000;
2136 if (sec > TIMET_MAX - sec2) {
2139 usec -= sec2 * 1000000;
2142 else if (usec < 0) {
2143 long sec2 =
NDIV(usec,1000000);
2144 if (sec < TIMET_MIN - sec2) {
2147 usec -= sec2 * 1000000;
2170 struct time_object *tobj;
2173 if (-86400 < offset && offset < 86400) {
2177 else if (offset == INT_MAX) {
2179 else if (offset == INT_MAX-1) {
2209 const char *
const tstr = interval ?
"time interval" :
"time";
2212 #ifndef NEGATIVE_TIME_T 2217 t.
tv_sec = NUM2TIMET(num);
2218 if (interval && t.
tv_sec < 0)
2231 if (t.
tv_nsec >= 1000000000) {
2236 else if ((t.
tv_nsec = (
int)(-d*1e9+0.5)) > 0) {
2247 t.
tv_sec = NUM2TIMET(num);
2248 if (interval && t.
tv_sec < 0)
2259 if (interval && t.
tv_sec < 0)
2294 struct time_object *tobj;
2311 struct time_object *tobj;
2374 struct time_object *tobj, *tobj2;
2389 "jan",
"feb",
"mar",
"apr",
"may",
"jun",
2390 "jul",
"aug",
"sep",
"oct",
"nov",
"dec",
2407 const uint32_t usable_mask = ~(u32max << bits);
2414 if ((rv & usable_mask) != rv)
2466 for (i=0; i<12; i++) {
2476 if (
'0' <= c && c <=
'9') {
2505 #define validate_vtm_range(mem, b, e) \ 2506 ((vtm->mem < b || vtm->mem > e) ? \ 2507 rb_raise(rb_eArgError, #mem" out of range") : (void)0) 2516 #undef validate_vtm_range 2531 vtm->utc_offset =
Qnil;
2545 vtm->isdst =
RTEST(argv[8]) ? 1 : 0;
2548 rb_scan_args(argc, argv,
"17", &v[0],&v[1],&v[2],&v[3],&v[4],&v[5],&v[6],&v[7]);
2575 if (!
NIL_P(v[6]) && argc == 7) {
2591 return ((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0);
2597 long tm_year = tm->tm_year;
2598 int tm_yday = tm->tm_mday;
2600 tm_yday += leap_year_yday_offset[tm->tm_mon];
2602 tm_yday += common_year_yday_offset[tm->tm_mon];
2610 return tm->tm_sec + tm->tm_min*60 + tm->tm_hour*3600 +
2614 DIV(tm_year-1,100) +
2615 DIV(tm_year+299,400))*86400;
2619 #define DEBUG_FIND_TIME_NUMGUESS 2620 #define DEBUG_GUESSRANGE 2623 #ifdef DEBUG_GUESSRANGE 2624 #define DEBUG_REPORT_GUESSRANGE fprintf(stderr, "find time guess range: %ld - %ld : %"PRI_TIMET_PREFIX"u\n", guess_lo, guess_hi, (unsigned_time_t)(guess_hi-guess_lo)) 2626 #define DEBUG_REPORT_GUESSRANGE 2629 #ifdef DEBUG_FIND_TIME_NUMGUESS 2630 #define DEBUG_FIND_TIME_NUMGUESS_INC find_time_numguess++, 2631 static unsigned long long find_time_numguess;
2633 static VALUE find_time_numguess_getter(
void)
2635 return ULL2NUM(find_time_numguess);
2638 #define DEBUG_FIND_TIME_NUMGUESS_INC 2644 time_t guess, guess0, guess_lo, guess_hi;
2645 struct tm *tm, tm0, tm_lo, tm_hi;
2652 #define GUESS(p) (DEBUG_FIND_TIME_NUMGUESS_INC (utc_p ? gmtime_with_leapsecond((p), &result) : LOCALTIME((p), result))) 2654 guess_lo = TIMET_MIN;
2655 guess_hi = TIMET_MAX;
2657 find_dst = 0 < tptr->tm_isdst;
2659 #if defined(HAVE_MKTIME) 2661 if (!utc_p && (guess = mktime(&tm0)) != -1) {
2663 if (tm &&
tmcmp(tptr, tm) == 0) {
2670 if (tm0.tm_mon < 0) {
2677 else if (11 < tm0.tm_mon) {
2684 else if (tm0.tm_mday < 1) {
2691 leap_year_days_in_month :
2692 common_year_days_in_month)[tm0.tm_mon]) < tm0.tm_mday) {
2698 else if (tm0.tm_hour < 0) {
2703 else if (23 < tm0.tm_hour) {
2708 else if (tm0.tm_min < 0) {
2712 else if (59 < tm0.tm_min) {
2716 else if (tm0.tm_sec < 0) {
2719 else if (60 < tm0.tm_sec) {
2727 d =
tmcmp(tptr, tm);
2728 if (d == 0) {
goto found; }
2731 guess -= 24 * 60 * 60;
2735 guess += 24 * 60 * 60;
2738 if (guess_lo < guess && guess < guess_hi && (tm =
GUESS(&guess)) !=
NULL) {
2739 d =
tmcmp(tptr, tm);
2740 if (d == 0) {
goto found; }
2749 tm =
GUESS(&guess_lo);
2750 if (!tm)
goto error;
2751 d =
tmcmp(tptr, tm);
2752 if (d < 0)
goto out_of_range;
2753 if (d == 0) { guess = guess_lo;
goto found; }
2756 tm =
GUESS(&guess_hi);
2757 if (!tm)
goto error;
2758 d =
tmcmp(tptr, tm);
2759 if (d > 0)
goto out_of_range;
2760 if (d == 0) { guess = guess_hi;
goto found; }
2767 while (guess_lo + 1 < guess_hi) {
2770 guess = guess_lo / 2 + guess_hi / 2;
2771 if (guess <= guess_lo)
2772 guess = guess_lo + 1;
2773 else if (guess >= guess_hi)
2774 guess = guess_hi - 1;
2780 guess = guess_hi - (guess0_hi - guess0);
2781 if (guess == guess_hi)
2785 else if (status == 2) {
2787 guess = guess_lo + (guess0 - guess0_lo);
2788 if (guess == guess_lo)
2792 if (guess <= guess_lo || guess_hi <= guess) {
2794 #ifdef DEBUG_GUESSRANGE 2795 if (guess <= guess_lo) fprintf(stderr,
"too small guess: %ld <= %ld\n", guess, guess_lo);
2796 if (guess_hi <= guess) fprintf(stderr,
"too big guess: %ld <= %ld\n", guess_hi, guess);
2803 if (!tm)
goto error;
2805 d =
tmcmp(tptr, tm);
2823 guess2 = guess - 2 * 60 * 60;
2826 if (tptr->tm_hour != (tm->tm_hour + 2) % 24 ||
2827 tptr->tm_min != tm->tm_min ||
2828 tptr->tm_sec != tm->tm_sec) {
2829 guess2 -= (tm->tm_hour - tptr->tm_hour) * 60 * 60 +
2830 (tm->tm_min - tptr->tm_min) * 60 +
2831 (tm->tm_sec - tptr->tm_sec);
2832 if (tptr->tm_mday != tm->tm_mday)
2833 guess2 += 24 * 60 * 60;
2834 if (guess != guess2) {
2836 if (tm &&
tmcmp(tptr, tm) == 0) {
2848 guess2 = guess + 2 * 60 * 60;
2851 if ((tptr->tm_hour + 2) % 24 != tm->tm_hour ||
2852 tptr->tm_min != tm->tm_min ||
2853 tptr->tm_sec != tm->tm_sec) {
2854 guess2 -= (tm->tm_hour - tptr->tm_hour) * 60 * 60 +
2855 (tm->tm_min - tptr->tm_min) * 60 +
2856 (tm->tm_sec - tptr->tm_sec);
2857 if (tptr->tm_mday != tm->tm_mday)
2858 guess2 -= 24 * 60 * 60;
2859 if (guess != guess2) {
2861 if (tm &&
tmcmp(tptr, tm) == 0) {
2886 tptr_tm_yday =
calc_tm_yday(tptr->tm_year, tptr->tm_mon, tptr->tm_mday);
2889 ((tptr->tm_year - tm_lo.tm_year) * 365 +
2890 ((tptr->tm_year-69)/4) -
2891 ((tptr->tm_year-1)/100) +
2892 ((tptr->tm_year+299)/400) -
2893 ((tm_lo.tm_year-69)/4) +
2894 ((tm_lo.tm_year-1)/100) -
2895 ((tm_lo.tm_year+299)/400) +
2897 tm_lo.tm_yday) * 86400 +
2898 (tptr->tm_hour - tm_lo.tm_hour) * 3600 +
2899 (tptr->tm_min - tm_lo.tm_min) * 60 +
2900 (tptr->tm_sec - (tm_lo.tm_sec == 60 ? 59 : tm_lo.tm_sec));
2905 return "time out of range";
2908 return "gmtime/localtime error";
2914 if (
ne(a->year, b->year))
2915 return lt(a->year, b->year) ? -1 : 1;
2916 else if (a->mon != b->mon)
2917 return a->mon < b->mon ? -1 : 1;
2918 else if (a->mday != b->mday)
2919 return a->mday < b->mday ? -1 : 1;
2920 else if (a->hour != b->hour)
2921 return a->hour < b->hour ? -1 : 1;
2922 else if (a->min != b->min)
2923 return a->min < b->min ? -1 : 1;
2924 else if (a->sec != b->sec)
2925 return a->sec < b->sec ? -1 : 1;
2926 else if (
ne(a->subsecx, b->subsecx))
2927 return lt(a->subsecx, b->subsecx) ? -1 : 1;
2935 if (a->tm_year != b->tm_year)
2936 return a->tm_year < b->tm_year ? -1 : 1;
2937 else if (a->tm_mon != b->tm_mon)
2938 return a->tm_mon < b->tm_mon ? -1 : 1;
2939 else if (a->tm_mday != b->tm_mday)
2940 return a->tm_mday < b->tm_mday ? -1 : 1;
2941 else if (a->tm_hour != b->tm_hour)
2942 return a->tm_hour < b->tm_hour ? -1 : 1;
2943 else if (a->tm_min != b->tm_min)
2944 return a->tm_min < b->tm_min ? -1 : 1;
2945 else if (a->tm_sec != b->tm_sec)
2946 return a->tm_sec < b->tm_sec ? -1 : 1;
3051 struct time_object *tobj;
3075 struct time_object *tobj;
3099 struct time_object *tobj;
3125 struct time_object *tobj;
3156 struct time_object *tobj;
3184 struct time_object *tobj;
3218 struct time_object *tobj1, *tobj2;
3224 n =
wcmp(tobj1->timew, tobj2->timew);
3229 if (n == 0)
return INT2FIX(0);
3245 struct time_object *tobj1, *tobj2;
3276 struct time_object *tobj;
3295 struct time_object *tobj;
3305 struct time_object *tobj, *tcopy;
3310 MEMCPY(tcopy, tobj,
struct time_object, 1);
3326 struct time_object *tobj;
3405 struct time_object *tobj;
3417 if (!
gmtimew(tobj->timew, &vtm))
3429 struct time_object *tobj;
3443 off = tobj->vtm.utc_offset;
3447 if (!
gmtimew(tobj->timew, &vtm))
3533 #define strftimev(fmt, time, enc) strftime_cstr((fmt), rb_strlen_lit(fmt), (time), (enc)) 3571 struct time_object *tobj;
3594 VALUE off = tobj->vtm.utc_offset;
3615 struct time_object *tobj;
3642 struct time_object *tobj;
3646 struct time_object *tobj2;
3672 struct time_object *tobj;
3673 struct time_object *tobj2;
3675 rb_warn(
"Time#succ is obsolete; use time + 1");
3683 #define time_succ rb_time_succ 3725 VALUE ndigits, v, a, b, den;
3727 struct time_object *tobj;
3776 struct time_object *tobj;
3780 return INT2FIX(tobj->vtm.sec);
3796 struct time_object *tobj;
3800 return INT2FIX(tobj->vtm.min);
3816 struct time_object *tobj;
3820 return INT2FIX(tobj->vtm.hour);
3838 struct time_object *tobj;
3842 return INT2FIX(tobj->vtm.mday);
3860 struct time_object *tobj;
3864 return INT2FIX(tobj->vtm.mon);
3880 struct time_object *tobj;
3884 return tobj->vtm.year;
3908 struct time_object *tobj;
3912 return INT2FIX((
int)tobj->vtm.wday);
3915 #define wday_p(n) {\ 3916 struct time_object *tobj;\ 3917 GetTimeval(time, tobj);\ 3918 MAKE_TM(time, tobj);\ 3919 return (tobj->vtm.wday == (n)) ? Qtrue : Qfalse;\ 4047 struct time_object *tobj;
4051 return INT2FIX(tobj->vtm.yday);
4082 struct time_object *tobj;
4118 struct time_object *tobj;
4126 if (tobj->vtm.zone ==
NULL)
4150 struct time_object *tobj;
4159 return tobj->vtm.utc_offset;
4183 struct time_object *tobj;
4202 struct vtm *vtm,
wideval_t timew,
int gmt)
4214 return rb_strftime(format, format_len, enc, vtm, timev, gmt);
4221 struct time_object *tobj;
4421 struct time_object *tobj;
4437 rb_warning(
"strftime called with empty format string");
4452 struct time_object *tobj;
4461 VALUE subsecx, nano, subnano, v;
4469 if (year < 1900 || 1900+0xffff < year)
4476 subsecx = vtm.subsecx;
4492 s = (
unsigned long)vtm.min << 26 |
4496 for (i=0; i<4; i++) {
4497 buf[i] = (
unsigned char)p;
4500 for (i=4; i<8; i++) {
4501 buf[i] = (
unsigned char)s;
4526 int len = (int)
sizeof(buf);
4527 buf[1] = (char)((nsec % 10) << 4);
4529 buf[0] = (char)(nsec % 10);
4531 buf[0] |= (char)((nsec % 10) << 4);
4543 if (tobj->vtm.zone) {
4565 struct time_object *tobj;
4573 VALUE submicro, nano_num, nano_den, offset, zone;
4578 #define get_attr(attr, iffound) \ 4579 attr = rb_attr_delete(str, id_##attr); \ 4580 if (!NIL_P(attr)) { \ 4601 for (i=0; i<4; i++) {
4602 p |= (
unsigned long)buf[i]<<(8*i);
4604 for (i=4; i<8; i++) {
4605 s |= (
unsigned long)buf[i]<<(8*(i-4));
4608 if ((p & (1UL<<31)) == 0) {
4618 gmt = (int)((p >> 30) & 0x1);
4620 vtm.year =
INT2FIX(((
int)(p >> 14) & 0xffff) + 1900);
4621 vtm.mon = ((int)(p >> 10) & 0xf) + 1;
4622 vtm.mday = (int)(p >> 5) & 0x1f;
4623 vtm.hour = (int) p & 0x1f;
4624 vtm.min = (int)(s >> 26) & 0x3f;
4625 vtm.sec = (int)(s >> 20) & 0x3f;
4627 vtm.yday = vtm.wday = 0;
4631 usec = (long)(s & 0xfffff);
4636 if (nano_num !=
Qnil) {
4640 else if (submicro !=
Qnil) {
4648 if (10 <= (digit = ptr[0] >> 4))
goto end_submicro;
4649 nsec += digit * 100;
4650 if (10 <= (digit = ptr[0] & 0xf))
goto end_submicro;
4654 if (10 <= (digit = ptr[1] >> 4))
goto end_submicro;
4666 tobj->timew = timew;
4670 else if (!
NIL_P(offset)) {
4785 #define rb_intern(str) rb_intern_const(str) 4885 #ifdef DEBUG_FIND_TIME_NUMGUESS #define STRNCASECMP(s1, s2, n)
static const rb_data_type_t time_data_type
VALUE rb_big_modulo(VALUE x, VALUE y)
VALUE rb_external_str_with_enc(VALUE str, rb_encoding *eenc)
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)
int rb_integer_pack(VALUE val, void *words, size_t numwords, size_t wordsize, size_t nails, int flags)
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 *)
#define RUBY_TYPED_FREE_IMMEDIATELY
static int obj2int(VALUE obj)
static VALUE time_sunday(VALUE time)
static VALUE time_getlocaltime(int argc, VALUE *argv, VALUE time)
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)
void rb_timespec_now(struct timespec *ts)
#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)
VALUE rb_time_timespec_new(const struct timespec *ts, int offset)
Returns a time object with UTC/localtime/fixed offset.
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)
VALUE rb_strftime_timespec(const char *format, size_t format_len, rb_encoding *enc, const struct vtm *vtm, struct timespec *ts, int gmt)
#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)
static struct tm * localtime_r(const time_t *t, struct tm *tm)
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
static const int common_year_days_in_month[]
#define INTEGER_PACK_NATIVE_BYTE_ORDER
VALUE rb_time_succ(VALUE time)
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)
static VALUE rb_fix_mul_fix(VALUE x, VALUE y)
VALUE rb_enc_associate(VALUE obj, rb_encoding *enc)
VALUE rb_strftime(const char *format, size_t format_len, rb_encoding *enc, const struct vtm *vtm, VALUE timev, int gmt)
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
static VALUE time_plus(VALUE time1, VALUE time2)
static wideval_t wsub(wideval_t wx, wideval_t wy)
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 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 uint32_t month_arg(VALUE arg)
static size_t time_memsize(const void *tobj)
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 struct tm * gmtime_r(const time_t *t, struct tm *tm)
static VALUE time_cmp(VALUE time1, VALUE time2)
int rb_cmpint(VALUE val, VALUE a, VALUE b)
static VALUE time_yday(VALUE time)
#define VTM_ISDST_INITVAL
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)
RUBY_SYMBOL_EXPORT_BEGIN typedef unsigned long st_data_t
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 VALUE time_zone_name(const char *zone)
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 validate_vtm_range(mem, b, e)
#define GetNewTimeval(obj, tobj)
static wideval_t wmod(wideval_t wx, wideval_t wy)
static struct tm * rb_gmtime_r(const time_t *t, struct tm *result)
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 VALUE mod(VALUE x, VALUE y)
#define LOCALTIME(tm, result)
static VALUE time_saturday(VALUE time)
#define TIME_FIXOFF_P(tobj)
void rb_check_trusted(VALUE obj)
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)
static wideval_t wdiv(wideval_t wx, wideval_t wy)
static struct tm * rb_localtime_r(const time_t *t, struct tm *result)
#define GMTIME(tm, result)
static VALUE strftime_cstr(const char *fmt, size_t len, VALUE time, rb_encoding *enc)
static const char * zone_str(const char *s)
PACKED_STRUCT_UNALIGNED(struct time_object { wideval_t timew;struct vtm vtm;uint8_t gmt:3;uint8_t tm_got:1;})
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)
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)
VALUE rb_class_new_instance(int, const VALUE *, VALUE)
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)
static VALUE time_to_f(VALUE time)
static const int leap_year_yday_offset[]
static VALUE time_getgmtime(VALUE time)
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)
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)
rb_encoding * rb_locale_encoding(void)
static st_table * zone_table
static uint32_t obj2ubits(VALUE obj, size_t bits)
#define rb_enc_str_asciicompat_p(str)
static struct timespec time_timespec(VALUE num, int interval)
static VALUE sub(VALUE x, VALUE y)
static VALUE rb_fix_mod_fix(VALUE x, VALUE y)
VALUE rb_check_funcall(VALUE, ID, int, const VALUE *)
int clock_gettime(clockid_t, struct timespec *)
VALUE rb_time_nano_new(time_t sec, long nsec)
static int timew_out_of_timet_range(wideval_t timew)
VALUE rb_str_new_cstr(const char *)
size_t rb_absint_size(VALUE val, int *nlz_bits_ret)
#define MUL_OVERFLOW_FIXWV_P(a, b)
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 VALUE validate_zone_name(VALUE zone_name)
#define RB_FLOAT_TYPE_P(obj)
#define TYPEOF_TIMEVAL_TV_USEC
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 rb_strftime_alloc(const char *format, size_t format_len, rb_encoding *enc, struct vtm *vtm, wideval_t timew, int gmt)
static VALUE time_thursday(VALUE time)
int rb_respond_to(VALUE, ID)
register unsigned int len
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)
VALUE rb_check_to_int(VALUE)
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 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 void rb_fix_divmod_fix(VALUE a, VALUE b, VALUE *divp, VALUE *modp)
static VALUE time_isdst(VALUE time)
static VALUE time_dup(VALUE time)
static uint32_t obj2subsecx(VALUE obj, VALUE *subsecx)
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 VALUE usec2subsecx(VALUE obj)
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)
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)
#define RUBY_TYPED_DEFAULT_FREE
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)
static VALUE time_year(VALUE time)
static VALUE rb_time_unmagnify_to_float(wideval_t w)
int rb_enc_str_asciionly_p(VALUE)
static VALUE time_init_copy(VALUE copy, VALUE time)
#define RB_INTEGER_TYPE_P(obj)
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)
#define strftimev(fmt, time, enc)
struct timeval rb_time_timeval(VALUE time)
VALUE rb_usascii_str_new_cstr(const char *)
#define TYPEOF_TIMEVAL_TV_SEC
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)