11 "Sunday",
"Monday",
"Tuesday",
"Wednesday",
12 "Thursday",
"Friday",
"Saturday",
13 "Sun",
"Mon",
"Tue",
"Wed",
18 "January",
"February",
"March",
"April",
19 "May",
"June",
"July",
"August",
"September",
20 "October",
"November",
"December",
21 "Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
22 "Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
36 #define sizeof_array(o) (sizeof o / sizeof o[0])
38 #define f_negate(x) rb_funcall(x, rb_intern("-@"), 0)
39 #define f_add(x,y) rb_funcall(x, '+', 1, y)
40 #define f_sub(x,y) rb_funcall(x, '-', 1, y)
41 #define f_mul(x,y) rb_funcall(x, '*', 1, y)
42 #define f_div(x,y) rb_funcall(x, '/', 1, y)
43 #define f_idiv(x,y) rb_funcall(x, rb_intern("div"), 1, y)
44 #define f_mod(x,y) rb_funcall(x, '%', 1, y)
45 #define f_expt(x,y) rb_funcall(x, rb_intern("**"), 1, y)
47 #define f_lt_p(x,y) rb_funcall(x, '<', 1, y)
48 #define f_gt_p(x,y) rb_funcall(x, '>', 1, y)
49 #define f_le_p(x,y) rb_funcall(x, rb_intern("<="), 1, y)
50 #define f_ge_p(x,y) rb_funcall(x, rb_intern(">="), 1, y)
52 #define f_match(r,s) rb_funcall(r, rb_intern("match"), 1, s)
53 #define f_aref(o,i) rb_funcall(o, rb_intern("[]"), 1, i)
54 #define f_end(o,i) rb_funcall(o, rb_intern("end"), 1, i)
56 #define issign(c) ((c) == '-' || (c) == '+')
61 if (isdigit((
unsigned char)*s))
65 if (*s ==
'E' || *s ==
'O')
68 (
strchr(
"CDdeFGgHIjkLlMmNQRrSsTUuVvWwXxYy", *s) ||
69 isdigit((
unsigned char)*s)))
75 #define NUM_PATTERN_P() num_pattern_p(&fmt[fi + 1])
82 l = strspn(s,
"0123456789");
90 if ((4 * l *
sizeof(
char)) <= (
sizeof(
long)*
CHAR_BIT)) {
95 while ((
size_t)(s - os) < l) {
114 #define set_hash(k,v) rb_hash_aset(hash, ID2SYM(rb_intern(k)), v)
115 #define ref_hash(k) rb_hash_aref(hash, ID2SYM(rb_intern(k)))
116 #define del_hash(k) rb_hash_delete(hash, ID2SYM(rb_intern(k)))
120 set_hash("_fail", Qtrue); \
124 #define fail_p() (!NIL_P(ref_hash("_fail")))
126 #define READ_DIGITS(n,w) \
129 l = read_digits(&str[si], &n, w); \
135 #define READ_DIGITS_MAX(n) READ_DIGITS(n, LONG_MAX)
142 return !(vi < a || vi > b);
150 l = date__strptime_internal(&str[si], slen - si, \
151 fmt, sizeof fmt - 1, hash); \
161 const char *fmt,
size_t flen,
VALUE hash)
179 if (fmt[fi + 1] &&
strchr(
"cCxXyY", fmt[fi + 1]))
184 if (fmt[fi + 1] &&
strchr(
"deHImMSuUVwWy", fmt[fi + 1]))
246 recur(
"%a %b %e %H:%M:%S %Y");
258 if (str[si] ==
' ') {
304 if (str[si] ==
' ') {
321 if (str[si] ==
' ') {
402 for (i = 0; i < 4; i++) {
418 if (str[si] ==
'-') {
437 recur(
"%I:%M:%S %p");
456 if (str[si] ==
'-') {
479 set_hash(c ==
'U' ?
"wnum0" :
"wnum1", n);
567 static const char pat_source[] =
569 "(?:gmt|utc?)?[-+]\\d+(?:[,.:]\\d+(?::\\d+)?)?"
570 "|[[:alpha:].\\s]+(?:standard|daylight)\\s+time\\b"
571 "|[[:alpha:]]+(?:\\s+dst)?\\b"
577 pat =
rb_reg_new(pat_source,
sizeof pat_source - 1,
609 recur(
"%a %b %e %H:%M:%S %Z %Y");
617 if (str[si] != fmt[fi])
628 while (isspace((
unsigned char)str[si]))
634 if (str[si] != fmt[fi])
650 const char *fmt,
size_t flen,
VALUE hash)
#define rb_rational_new2(x, y)
size_t strlen(const char *)
void rb_backref_set(VALUE)
static const char * month_names[]
VALUE rb_backref_get(void)
VALUE date__strptime(const char *str, size_t slen, const char *fmt, size_t flen, VALUE hash)
#define READ_DIGITS(n, w)
static int valid_range_p(VALUE v, int a, int b)
static int num_pattern_p(const char *s)
#define ALLOCA_N(type, n)
void rb_gc_register_mark_object(VALUE obj)
static const char * day_names[]
static long read_digits(const char *s, VALUE *n, size_t width)
VALUE rb_reg_new(const char *, long, int)
static const char * extz_pats[]
#define READ_DIGITS_MAX(n)
char * strchr(char *, char)
void rb_match_busy(VALUE)
static const char * merid_names[]
VALUE rb_usascii_str_new2(const char *)
static size_t date__strptime_internal(const char *str, size_t slen, const char *fmt, size_t flen, VALUE hash)
static unsigned int hash(const char *str, unsigned int len)
#define ONIG_OPTION_IGNORECASE
VALUE rb_cstr_to_inum(const char *str, int base, int badcheck)
VALUE rb_usascii_str_new(const char *, long)
VALUE date_zone_to_diff(VALUE)
VALUE rb_reg_nth_match(int, VALUE)