15 #define sizeof_array(o) (sizeof o / sizeof o[0]) 17 #define f_negate(x) rb_funcall(x, rb_intern("-@"), 0) 18 #define f_add(x,y) rb_funcall(x, '+', 1, y) 19 #define f_sub(x,y) rb_funcall(x, '-', 1, y) 20 #define f_mul(x,y) rb_funcall(x, '*', 1, y) 21 #define f_div(x,y) rb_funcall(x, '/', 1, y) 22 #define f_idiv(x,y) rb_funcall(x, rb_intern("div"), 1, y) 23 #define f_mod(x,y) rb_funcall(x, '%', 1, y) 24 #define f_expt(x,y) rb_funcall(x, rb_intern("**"), 1, y) 26 #define f_lt_p(x,y) rb_funcall(x, '<', 1, y) 27 #define f_gt_p(x,y) rb_funcall(x, '>', 1, y) 28 #define f_le_p(x,y) rb_funcall(x, rb_intern("<="), 1, y) 29 #define f_ge_p(x,y) rb_funcall(x, rb_intern(">="), 1, y) 31 #define f_to_s(x) rb_funcall(x, rb_intern("to_s"), 0) 33 #define f_match(r,s) rb_funcall(r, rb_intern("match"), 1, s) 34 #define f_aref(o,i) rb_funcall(o, rb_intern("[]"), 1, i) 35 #define f_aref2(o,i,j) rb_funcall(o, rb_intern("[]"), 2, i, j) 36 #define f_begin(o,i) rb_funcall(o, rb_intern("begin"), 1, i) 37 #define f_end(o,i) rb_funcall(o, rb_intern("end"), 1, i) 38 #define f_aset(o,i,v) rb_funcall(o, rb_intern("[]="), 2, i, v) 39 #define f_aset2(o,i,j,v) rb_funcall(o, rb_intern("[]="), 3, i, j, v) 40 #define f_sub_bang(s,r,x) rb_funcall(s, rb_intern("sub!"), 2, r, x) 41 #define f_gsub_bang(s,r,x) rb_funcall(s, rb_intern("gsub!"), 2, r, x) 43 #define set_hash(k,v) rb_hash_aset(hash, ID2SYM(rb_intern(k)), v) 44 #define ref_hash(k) rb_hash_aref(hash, ID2SYM(rb_intern(k))) 45 #define del_hash(k) rb_hash_delete(hash, ID2SYM(rb_intern(k))) 47 #define cstr2num(s) rb_cstr_to_inum(s, 10, 0) 48 #define str2num(s) rb_str_to_inum(s, 10, 0) 50 static const char abbr_days[][4] = {
51 "sun",
"mon",
"tue",
"wed",
55 static const char abbr_months[][4] = {
56 "jan",
"feb",
"mar",
"apr",
"may",
"jun",
57 "jul",
"aug",
"sep",
"oct",
"nov",
"dec" 60 #define issign(c) ((c) == '-' || (c) == '+') 61 #define asp_string() rb_str_new(" ", 1) 63 #define asuba_string() rb_str_new("\001", 1) 64 #define asubb_string() rb_str_new("\002", 1) 65 #define asubw_string() rb_str_new("\027", 1) 66 #define asubt_string() rb_str_new("\024", 1) 69 #define DECDIGIT "0123456789" 102 const char *s, *
bp, *ep;
106 while (!
issign((
unsigned char)*s) && !isdigit((
unsigned char)*s))
109 if (
issign((
unsigned char)*s))
149 const char *s, *
bp, *ep;
155 while (!
issign((
unsigned char)*s) && !isdigit((
unsigned char)*s))
171 buf =
ALLOCV_N(
char, vbuf, ep - bp + 1);
172 memcpy(buf, bp, ep - bp);
184 const char *s, *
bp, *ep;
189 while (!isdigit((
unsigned char)*s))
197 buf =
ALLOCV_N(
char, vbuf, ep - bp + 1);
198 memcpy(buf, bp, ep - bp);
207 const char *s, *
bp, *ep;
212 while (!isdigit((
unsigned char)*s))
220 buf =
ALLOCV_N(
char, vbuf, ep - bp + 1);
221 memcpy(buf, bp, ep - bp);
233 #define DAYS "sunday|monday|tuesday|wednesday|thursday|friday|saturday" 234 #define MONTHS "january|february|march|april|may|june|july|august|september|october|november|december" 235 #define ABBR_DAYS "sun|mon|tue|wed|thu|fri|sat" 236 #define ABBR_MONTHS "jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec" 239 #define VALID_DAYS "(?:" DAYS ")" "|(?:tues|wednes|thurs|thur|" ABBR_DAYS ")\\.?" 240 #define VALID_MONTHS "(?:" MONTHS ")" "|(?:sept|" ABBR_MONTHS ")\\.?" 241 #define DOTLESS_VALID_MONTHS "(?:" MONTHS ")" "|(?:sept|" ABBR_MONTHS ")" 242 #define BOS "\\A\\s*" 247 #define FPW_COM "\\s*(?:" FPW "\\s*,?)?\\s*" 248 #define FPT_COM "\\s*(?:" FPT "\\s*,?)?\\s*" 249 #define COM_FPW "\\s*(?:,?\\s*" FPW ")?\\s*" 250 #define COM_FPT "\\s*(?:,?\\s*(?:@|\\b[aA][tT]\\b)?\\s*" FPT ")?\\s*" 251 #define TEE_FPT "\\s*(?:[tT]?" FPT ")?" 252 #define EOS "\\s*\\z" 256 regcomp(
const char *source,
long len,
int opt)
265 #define REGCOMP(pat,opt) \ 268 pat = regcomp(pat##_source, sizeof pat##_source - 1, opt); \ 271 #define REGCOMP_0(pat) REGCOMP(pat, 0) 272 #define REGCOMP_I(pat) REGCOMP(pat, ONIG_OPTION_IGNORECASE) 274 #define MATCH(s,p,c) \ 276 return match(s, p, hash, c); \ 316 #define SUBS(s,p,c) \ 318 return subx(s, asp_string(), p, hash, c); \ 322 #define SUBA(s,p,c) \ 324 return subx(s, asuba_string(), p, hash, c); \ 327 #define SUBB(s,p,c) \ 329 return subx(s, asubb_string(), p, hash, c); \ 332 #define SUBW(s,p,c) \ 334 return subx(s, asubw_string(), p, hash, c); \ 337 #define SUBT(s,p,c) \ 339 return subx(s, asubt_string(), p, hash, c); \ 346 str_end_with(
const char *s,
long l,
const char *w)
349 return (l >= n && strncmp(s - n, w, n) == 0);
365 dest = d =
ALLOCV_N(
char, vbuf, l + 1);
367 for (i = 0; i < l; i++) {
368 if (isspace((
unsigned char)s[i]) || s[i] ==
'\0') {
374 if (isalpha((
unsigned char)s[i]))
375 *d++ = tolower((
unsigned char)s[i]);
389 static const char STD[] =
" standard time";
390 static const char DST1[] =
" daylight time";
391 static const char DST2[] =
" dst";
394 if (str_end_with(d, l, STD)) {
395 l -=
sizeof(STD) - 1;
397 else if (str_end_with(d, l, DST1)) {
398 l -=
sizeof(DST1) - 1;
401 else if (str_end_with(d, l, DST2)) {
402 l -=
sizeof(DST2) - 1;
406 const struct zone *z =
zonetab(s, (
unsigned int)l);
418 long hour = 0, min = 0, sec = 0;
421 (strncmp(s,
"gmt", 3) == 0 ||
422 strncmp(s,
"utc", 3) == 0)) {
441 if (*p ==
',' || *p ==
'.') {
444 min =
STRTOUL(p, &e, 10) * 3600;
467 sec += min * 60 + hour * 3600;
468 if (sign) sec = -sec;
514 static const char pat_source[] =
525 SUBS(str, pat, parse_day_cb);
527 SUBW(str, pat, parse_day_cb);
577 static const char pat_source[] =
579 "(?:\\s*:?\\s*(\\d+)m?" 581 "\\s*:?\\s*(\\d+)(?:[,.](\\d+))?s?" 584 "(?:\\s*([ap])(?:m\\b|\\.m\\.))?";
601 parse_time2_cb(m, hash);
610 static const char pat_source[] =
616 "\\s*:\\s*\\d+(?:[,.]\\d*)?" 618 "\\s*:\\s*\\d+(?:[,.]\\d+)?" 622 "\\d+\\s*h(?:\\s*\\d+m?(?:\\s*\\d+s?)?)?" 626 "[ap](?:m\\b|\\.m\\.)" 629 "\\d+\\s*[ap](?:m\\b|\\.m\\.)" 634 "(?:gmt|utc?)?[-+]\\d+(?:[,.:]\\d+(?::\\d+)?)?" 636 "(?-i:[[:alpha:].\\s]+)(?:standard|daylight)\\stime\\b" 638 "(?-i:[[:alpha:]]+)(?:\\sdst)?\\b" 645 SUBS(str, pat, parse_time_cb);
647 SUBT(str, pat, parse_time_cb);
661 static const char pat_source[] =
666 SUBA(str, pat, parse_era1_cb);
684 static const char pat_source[] =
685 "(c(?:e|\\.e\\.)|b(?:ce|\\.c\\.e\\.)|b(?:c|\\.c\\.))";
689 SUBB(str, pat, parse_era2_cb);
695 if (parse_era1(str, hash))
697 if (parse_era2(str, hash))
707 check_year_width(
VALUE y)
727 if (!check_year_width(a))
732 if (!check_year_width(b))
739 if (!check_year_width(c))
762 s3e(hash, y, mon, d, !
NIL_P(b) &&
772 if (!check_apost(d, mon, y))
777 s3e(hash, y, mon, d, 0);
785 static const char pat_source[] =
791 "('?\\d+)[^-\\d\\s]*" 793 "(\\d+)(?:(?:st|nd|rd|th)\\b)?" 804 "(c(?:e|\\.e\\.)|b(?:ce|\\.c\\.e\\.)|a(?:d|\\.d\\.)|b(?:c|\\.c\\.))?" 806 "('?-?\\d+(?:(?:st|nd|rd|th)\\b)?)" 812 "(?:" FPA
"|" FPB
")?" 823 SUBS(str, pat, parse_eu_cb);
840 s3e(hash, y, mon, d, !
NIL_P(b) &&
850 if (!check_apost(mon, d, y))
855 s3e(hash, y, mon, d, 0);
863 static const char pat_source[] =
871 "\\b(" VALID_MONTHS
")" 875 "('?\\d+)[^-\\d\\s']*" 877 "('?\\d+)(?:(?:st|nd|rd|th)\\b)?" 884 "(c(?:e|\\.e\\.)|b(?:ce|\\.c\\.e\\.)|a(?:d|\\.d\\.)|b(?:c|\\.c\\.))?" 892 "(?:" FPA
"|" FPB
")?" 903 SUBS(str, pat, parse_us_cb);
916 if (!check_apost(y, mon, d))
920 s3e(hash, y, mon, d, 0);
927 static const char pat_source[] =
929 "('?[-+]?\\d+)-(\\d+)-('?-?\\d+)" 933 "([-+']?\\d+)-(\\d+)-([-']?\\d+)" 941 SUBS(str, pat, parse_iso_cb);
965 static const char pat_source[] =
967 "\\b(\\d{2}|\\d{4})?-?w(\\d{2})(?:-?(\\d))?\\b" 971 "(\\d{2}|\\d{4})?-?w(\\d{2})(?:-?(\\d))?" 979 SUBS(str, pat, parse_iso21_cb);
995 static const char pat_source[] =
1009 SUBS(str, pat, parse_iso22_cb);
1030 static const char pat_source[] =
1031 #ifndef TIGHT_PARSER 1032 "--(\\d{2})?-(\\d{2})\\b" 1036 "--(\\d{2})?-(\\d{2})" 1044 SUBS(str, pat, parse_iso23_cb);
1065 static const char pat_source[] =
1066 #ifndef TIGHT_PARSER 1067 "--(\\d{2})(\\d{2})?\\b" 1071 "--(\\d{2})(\\d{2})?" 1079 SUBS(str, pat, parse_iso24_cb);
1099 static const char pat0_source[] =
1100 #ifndef TIGHT_PARSER 1101 "[,.](\\d{2}|\\d{4})-\\d{3}\\b" 1105 "[,.](\\d{2}|\\d{4})-\\d{3}" 1111 static const char pat_source[] =
1112 #ifndef TIGHT_PARSER 1113 "\\b(\\d{2}|\\d{4})-(\\d{3})\\b" 1117 "(\\d{2}|\\d{4})-(\\d{3})" 1129 SUBS(str, pat, parse_iso25_cb);
1145 static const char pat0_source[] =
1146 #ifndef TIGHT_PARSER 1157 static const char pat_source[] =
1158 #ifndef TIGHT_PARSER 1175 SUBS(str, pat, parse_iso26_cb);
1181 if (parse_iso21(str, hash))
1183 if (parse_iso22(str, hash))
1185 if (parse_iso23(str, hash))
1187 if (parse_iso24(str, hash))
1189 if (parse_iso25(str, hash))
1191 if (parse_iso26(str, hash))
1205 case 'M':
case 'm': e = 1867;
break;
1206 case 'T':
case 't': e = 1911;
break;
1207 case 'S':
case 's': e = 1925;
break;
1208 case 'H':
case 'h': e = 1988;
break;
1209 default: e = 0;
break;
1237 static const char pat_source[] =
1238 #ifndef TIGHT_PARSER 1239 "\\b([mtsh])(\\d+)\\.(\\d+)\\.(\\d+)" 1243 "([mtsh])(\\d+)\\.(\\d+)\\.(\\d+)" 1251 SUBS(str, pat, parse_jis_cb);
1264 if (!check_apost(d, mon, y))
1270 s3e(hash, y, mon, d, 0);
1277 static const char pat_source[] =
1278 #ifndef TIGHT_PARSER 1284 "([-']?\\d+)-(" DOTLESS_VALID_MONTHS
")" 1293 SUBS(str, pat, parse_vms11_cb);
1306 if (!check_apost(mon, d, y))
1312 s3e(hash, y, mon, d, 0);
1319 static const char pat_source[] =
1320 #ifndef TIGHT_PARSER 1322 "-('?-?\\d+)(?:-('?-?\\d+))?" 1326 "(" DOTLESS_VALID_MONTHS
")" 1327 "-([-']?\\d+)(?:-([-']?\\d+))?" 1335 SUBS(str, pat, parse_vms12_cb);
1341 if (parse_vms11(str, hash))
1343 if (parse_vms12(str, hash))
1361 if (!check_apost(y, mon, d))
1365 s3e(hash, y, mon, d, 0);
1372 static const char pat_source[] =
1373 #ifndef TIGHT_PARSER 1374 "('?-?\\d+)/\\s*('?\\d+)(?:\\D\\s*('?-?\\d+))?" 1378 "([-']?\\d+)/\\s*('?\\d+)(?:(?:[-/]|\\s+)\\s*([-']?\\d+))?" 1386 SUBS(str, pat, parse_sla_cb);
1399 if (!check_apost(d, mon, y))
1404 s3e(hash, y, mon, d, 0);
1411 static const char pat_source[] =
1414 "([-']?\\d+)/\\s*(" DOTLESS_VALID_MONTHS
")(?:(?:[-/]|\\s+)\\s*([-']?\\d+))?" 1421 SUBS(str, pat, parse_sla2_cb);
1433 if (!check_apost(mon, d, y))
1438 s3e(hash, y, mon, d, 0);
1445 static const char pat_source[] =
1448 "(" DOTLESS_VALID_MONTHS
")/\\s*([-']?\\d+)(?:(?:[-/]|\\s+)\\s*([-']?\\d+))?" 1455 SUBS(str, pat, parse_sla3_cb);
1469 if (!check_apost(y, mon, d))
1473 s3e(hash, y, mon, d, 0);
1480 static const char pat_source[] =
1481 #ifndef TIGHT_PARSER 1482 "('?-?\\d+)\\.\\s*('?\\d+)\\.\\s*('?-?\\d+)" 1486 "([-']?\\d+)\\.\\s*(\\d+)\\.\\s*([-']?\\d+)" 1494 SUBS(str, pat, parse_dot_cb);
1507 if (!check_apost(d, mon, y))
1512 s3e(hash, y, mon, d, 0);
1519 static const char pat_source[] =
1522 "([-']?\\d+)\\.\\s*(" DOTLESS_VALID_MONTHS
")(?:(?:[./])\\s*([-']?\\d+))?" 1529 SUBS(str, pat, parse_dot2_cb);
1541 if (!check_apost(mon, d, y))
1546 s3e(hash, y, mon, d, 0);
1553 static const char pat_source[] =
1556 "(" DOTLESS_VALID_MONTHS
")\\.\\s*([-']?\\d+)(?:(?:[./])\\s*([-']?\\d+))?" 1563 SUBS(str, pat, parse_dot3_cb);
1580 static const char pat_source[] =
1581 #ifndef TIGHT_PARSER 1594 SUBS(str, pat, parse_year_cb);
1610 static const char pat_source[] =
1611 #ifndef TIGHT_PARSER 1616 "(" VALID_MONTHS
")" 1624 SUBS(str, pat, parse_mon_cb);
1640 static const char pat_source[] =
1641 #ifndef TIGHT_PARSER 1642 "(\\d+)(st|nd|rd|th)\\b" 1646 "(\\d+)(st|nd|rd|th)" 1654 SUBS(str, pat, parse_mday_cb);
1658 n2i(
const char *s,
long f,
long w)
1665 for (i = f; i < e; i++) {
1675 VALUE s1, s2, s3, s4, s5;
1676 const char *cs2, *cs3, *cs5;
1677 long l2, l3, l4, l5;
1712 int y = n2i(cs2, 0, 2);
1732 int y = n2i(cs2, l2-12, 2);
1738 int y = n2i(cs2, l2-14, 4);
1746 int y = n2i(cs2, 0, 4);
1776 int y = n2i(cs2, 0, 2);
1791 int y = n2i(cs2, 0, 4);
1851 memcpy(buf, cs5, l5);
1866 if (isdigit((
unsigned char)*s1))
1880 static const char pat_source[] =
1884 "([-+]?)(\\d{2,14})" 1889 "(\\d{2,6})?(?:[,.](\\d*))?" 1898 "\\[[-+]?\\d[^\\]]*\\]" 1908 SUBS(str, pat, parse_ddd_cb);
1911 #ifndef TIGHT_PARSER 1922 static const char pat_source[] =
1923 "\\b(bc\\b|bce\\b|b\\.c\\.|b\\.c\\.e\\.)";
1927 SUBS(str, pat, parse_bc_cb);
1956 static const char pat_source[] =
"\\A\\s*(\\d{1,2})\\s*\\z";
1960 SUBS(str, pat, parse_frag_cb);
1974 static const char pat_source[] =
"\\A\\s*" FPW
"\\s*\\z";
1978 SUBS(str, pat, parse_dummy_cb);
1984 static const char pat_source[] =
"\\A\\s*" FPT "\\s*\\z";
1988 SUBS(str, pat, parse_dummy_cb);
1994 static const char pat_source[] =
"\\A\\s*(" FPW
"\\s+" FPT "|" FPT "\\s+" FPW
")\\s*\\z";
1998 SUBS(str, pat, parse_dummy_cb);
2002 have_invalid_char_p(
VALUE s)
2014 #define HAVE_ALPHA (1<<0) 2015 #define HAVE_DIGIT (1<<1) 2016 #define HAVE_DASH (1<<2) 2017 #define HAVE_DOT (1<<3) 2018 #define HAVE_SLASH (1<<4) 2021 check_class(
VALUE s)
2042 #define HAVE_ELEM_P(x) ((check_class(str) & (x)) == (x)) 2045 #define PARSER_ERROR return rb_hash_new() 2051 VALUE backref, hash;
2054 if (have_invalid_char_p(str))
2062 static const char pat_source[] =
2063 #ifndef TIGHT_PARSER 2064 "[^-+',./:@[:alnum:]\\[\\]]+" 2080 parse_day(str, hash);
2082 parse_time(str, hash);
2086 parse_era(str, hash);
2090 if (parse_eu(str, hash))
2092 if (parse_us(str, hash))
2096 if (parse_iso(str, hash))
2099 if (parse_jis(str, hash))
2102 if (parse_vms(str, hash))
2105 if (parse_sla(str, hash))
2109 if (parse_sla2(str, hash))
2111 if (parse_sla3(str, hash))
2116 if (parse_dot(str, hash))
2120 if (parse_dot2(str, hash))
2122 if (parse_dot3(str, hash))
2127 if (parse_iso2(str, hash))
2130 if (parse_year(str, hash))
2133 if (parse_mon(str, hash))
2136 if (parse_mday(str, hash))
2139 if (parse_ddd(str, hash))
2143 if (parse_wday_only(str, hash))
2145 if (parse_time_only(str, hash))
2147 if (parse_wday_and_time(str, hash))
2154 #ifndef TIGHT_PARSER 2156 parse_bc(str, hash);
2158 parse_frag(str, hash);
2215 comp_year69(
VALUE y)
2223 comp_year50(
VALUE y)
2231 sec_fraction(
VALUE f)
2248 for (i = 1; i <=
SNUM; i++)
2267 else if (!
NIL_P(s[5])) {
2276 else if (!
NIL_P(s[8])) {
2286 else if (!
NIL_P(s[9])) {
2289 if (!
NIL_P(s[10])) {
2295 if (!
NIL_P(s[13])) {
2296 set_hash(
"sec_fraction", sec_fraction(s[13]));
2298 if (!
NIL_P(s[14])) {
2309 static const char pat_source[] =
2310 "\\A\\s*(?:([-+]?\\d{2,}|-)-(\\d{2})?-(\\d{2})|" 2311 "([-+]?\\d{2,})?-(\\d{3})|" 2312 "(\\d{4}|\\d{2})?-w(\\d{2})-(\\d)|" 2315 "(\\d{2}):(\\d{2})(?::(\\d{2})(?:[,.](\\d+))?)?" 2316 "(z|[-+]\\d{2}(?::?\\d{2})?)?)?\\s*\\z";
2320 MATCH(str, pat, iso8601_ext_datetime_cb);
2334 for (i = 1; i <=
SNUM; i++)
2353 else if (!
NIL_P(s[5])) {
2360 else if (!
NIL_P(s[6])) {
2363 else if (!
NIL_P(s[9])) {
2371 else if (!
NIL_P(s[11])) {
2375 else if (!
NIL_P(s[12])) {
2378 if (!
NIL_P(s[13])) {
2384 if (!
NIL_P(s[16])) {
2385 set_hash(
"sec_fraction", sec_fraction(s[16]));
2387 if (!
NIL_P(s[17])) {
2398 static const char pat_source[] =
2399 "\\A\\s*(?:([-+]?(?:\\d{4}|\\d{2})|--)(\\d{2}|-)(\\d{2})|" 2400 "([-+]?(?:\\d{4}|\\d{2}))(\\d{3})|" 2402 "(\\d{4}|\\d{2})w(\\d{2})(\\d)|" 2406 "(\\d{2})(\\d{2})(?:(\\d{2})(?:[,.](\\d+))?)?" 2407 "(z|[-+]\\d{2}(?:\\d{2})?)?)?\\s*\\z";
2411 MATCH(str, pat, iso8601_bas_datetime_cb);
2425 for (i = 1; i <=
SNUM; i++)
2434 set_hash(
"sec_fraction", sec_fraction(s[4]));
2443 #define iso8601_bas_time_cb iso8601_ext_time_cb 2448 static const char pat_source[] =
2449 "\\A\\s*(\\d{2}):(\\d{2})(?::(\\d{2})(?:[,.](\\d+))?" 2450 "(z|[-+]\\d{2}(:?\\d{2})?)?)?\\s*\\z";
2454 MATCH(str, pat, iso8601_ext_time_cb);
2460 static const char pat_source[] =
2461 "\\A\\s*(\\d{2})(\\d{2})(?:(\\d{2})(?:[,.](\\d+))?" 2462 "(z|[-+]\\d{2}(\\d{2})?)?)?\\s*\\z";
2472 VALUE backref, hash;
2479 if (iso8601_ext_datetime(str, hash))
2481 if (iso8601_bas_datetime(str, hash))
2483 if (iso8601_ext_time(str, hash))
2485 if (iso8601_bas_time(str, hash))
2505 for (i = 1; i <=
SNUM; i++)
2518 set_hash(
"sec_fraction", sec_fraction(s[7]));
2526 static const char pat_source[] =
2527 "\\A\\s*(-?\\d{4})-(\\d{2})-(\\d{2})" 2529 "(\\d{2}):(\\d{2}):(\\d{2})(?:\\.(\\d+))?" 2530 "(z|[-+]\\d{2}:\\d{2})\\s*\\z";
2534 MATCH(str, pat, rfc3339_cb);
2540 VALUE backref, hash;
2562 for (i = 1; i <=
SNUM; i++)
2578 set_hash(
"sec_fraction", sec_fraction(s[7]));
2590 static const char pat_source[] =
2591 "\\A\\s*(-?\\d{4,})(?:-(\\d{2})(?:-(\\d{2}))?)?" 2593 "(\\d{2}):(\\d{2}):(\\d{2})(?:\\.(\\d+))?)?" 2594 "(z|[-+]\\d{2}:\\d{2})?\\s*\\z";
2598 MATCH(str, pat, xmlschema_datetime_cb);
2612 for (i = 1; i <=
SNUM; i++)
2621 set_hash(
"sec_fraction", sec_fraction(s[4]));
2633 static const char pat_source[] =
2634 "\\A\\s*(\\d{2}):(\\d{2}):(\\d{2})(?:\\.(\\d+))?" 2635 "(z|[-+]\\d{2}:\\d{2})?\\s*\\z";
2639 MATCH(str, pat, xmlschema_time_cb);
2653 for (i = 1; i <=
SNUM; i++)
2674 static const char pat_source[] =
2675 "\\A\\s*(?:--(\\d{2})(?:-(\\d{2}))?|---(\\d{2}))" 2676 "(z|[-+]\\d{2}:\\d{2})?\\s*\\z";
2680 MATCH(str, pat, xmlschema_trunc_cb);
2686 VALUE backref, hash;
2693 if (xmlschema_datetime(str, hash))
2695 if (xmlschema_time(str, hash))
2697 if (xmlschema_trunc(str, hash))
2717 for (i = 1; i <=
SNUM; i++)
2743 static const char pat_source[] =
2748 "(\\d{2}):(\\d{2})(?::(\\d{2}))?\\s*" 2749 "([-+]\\d{4}|ut|gmt|e[sd]t|c[sd]t|m[sd]t|p[sd]t|[a-ik-z])\\s*\\z";
2753 MATCH(str, pat, rfc2822_cb);
2759 VALUE backref, hash;
2781 for (i = 1; i <=
SNUM; i++)
2801 static const char pat_source[] =
2806 "(\\d{2}):(\\d{2}):(\\d{2})\\s+" 2811 MATCH(str, pat, httpdate_type1_cb);
2825 for (i = 1; i <=
SNUM; i++)
2848 static const char pat_source[] =
2849 "\\A\\s*(" DAYS ")\\s*,\\s+" 2853 "(\\d{2}):(\\d{2}):(\\d{2})\\s+" 2858 MATCH(str, pat, httpdate_type2_cb);
2872 for (i = 1; i <=
SNUM; i++)
2890 static const char pat_source[] =
2894 "(\\d{2}):(\\d{2}):(\\d{2})\\s+" 2899 MATCH(str, pat, httpdate_type3_cb);
2905 VALUE backref, hash;
2912 if (httpdate_type1(str, hash))
2914 if (httpdate_type2(str, hash))
2916 if (httpdate_type3(str, hash))
2937 for (i = 1; i <=
SNUM; i++)
2953 set_hash(
"sec_fraction", sec_fraction(s[8]));
2965 static const char pat_source[] =
2966 "\\A\\s*([mtsh])?(\\d{2})\\.(\\d{2})\\.(\\d{2})" 2968 "(?:(\\d{2}):(\\d{2})(?::(\\d{2})(?:[,.](\\d*))?)?" 2969 "(z|[-+]\\d{2}(?::?\\d{2})?)?)?)?\\s*\\z";
2973 MATCH(str, pat, jisx0301_cb);
2979 VALUE backref, hash;
2985 if (jisx0301(str, hash))
#define rb_rational_new2(x, y)
size_t strlen(const char *)
void rb_backref_set(VALUE)
VALUE rb_backref_get(void)
RUBY_EXTERN unsigned long ruby_scan_digits(const char *str, ssize_t len, int base, size_t *retlen, int *overflow)
#define RB_TYPE_P(obj, type)
VALUE date__xmlschema(VALUE str)
#define STRTOUL(str, endptr, base)
VALUE date__parse(VALUE str, VALUE comp)
VALUE date_zone_to_diff(VALUE str)
VALUE date__rfc2822(VALUE str)
VALUE date__jisx0301(VALUE str)
#define ALLOCV_N(type, v, n)
VALUE rb_rational_new(VALUE, VALUE)
void rb_gc_register_mark_object(VALUE obj)
RUBY_EXTERN VALUE rb_int_positive_pow(long x, unsigned long y)
VALUE rb_reg_new(const char *, long, int)
unsigned char buf[MIME_BUF_SIZE]
char * strchr(char *, char)
void rb_match_busy(VALUE)
register unsigned int len
#define iso8601_bas_time_cb
#define f_gsub_bang(s, r, x)
VALUE date__httpdate(VALUE str)
#define f_aset2(o, i, j, v)
VALUE date__rfc3339(VALUE str)
const struct zone * zonetab(str, len) register const char *str
VALUE date__iso8601(VALUE str)
VALUE rb_reg_nth_match(int, VALUE)
VALUE rb_str_new(const char *, long)