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) == '+')
65 if (*s ==
'E' || *s ==
'O')
68 (
strchr(
"CDdeFGgHIjkLlMmNQRrSsTUuVvWwXxYy", *s) || isdigit(*s)))
74 #define NUM_PATTERN_P() num_pattern_p(&fmt[fi + 1])
81 l = strspn(s,
"0123456789");
89 if ((4 * l *
sizeof(
char)) <= (
sizeof(
long)*
CHAR_BIT)) {
94 while ((
size_t)(s - os) < l) {
113 #define set_hash(k,v) rb_hash_aset(hash, ID2SYM(rb_intern(k)), v)
114 #define ref_hash(k) rb_hash_aref(hash, ID2SYM(rb_intern(k)))
115 #define del_hash(k) rb_hash_delete(hash, ID2SYM(rb_intern(k)))
119 set_hash("_fail", Qtrue); \
123 #define fail_p() (!NIL_P(ref_hash("_fail")))
125 #define READ_DIGITS(n,w) \
128 l = read_digits(&str[si], &n, w); \
134 #define READ_DIGITS_MAX(n) READ_DIGITS(n, LONG_MAX)
141 return !(vi < a || vi >
b);
149 l = date__strptime_internal(&str[si], slen - si, \
150 fmt, sizeof fmt - 1, hash); \
178 if (fmt[fi + 1] &&
strchr(
"cCxXyY", fmt[fi + 1]))
183 if (fmt[fi + 1] &&
strchr(
"deHImMSuUVwWy", fmt[fi + 1]))
245 recur(
"%a %b %e %H:%M:%S %Y");
257 if (str[si] ==
' ') {
303 if (str[si] ==
' ') {
320 if (str[si] ==
' ') {
401 for (i = 0; i < 4; i++) {
417 if (str[si] ==
'-') {
436 recur(
"%I:%M:%S %p");
455 if (str[si] ==
'-') {
478 set_hash(c ==
'U' ?
"wnum0" :
"wnum1", n);
566 static const char pat_source[] =
568 "(?:gmt|utc?)?[-+]\\d+(?:[,.:]\\d+(?::\\d+)?)?"
569 "|(?-i:[[:alpha:].\\s]+)(?:standard|daylight)\\s+time\\b"
570 "|(?-i:[[:alpha:]]+)(?:\\s+dst)?\\b"
576 pat =
rb_reg_new(pat_source,
sizeof pat_source - 1,
608 recur(
"%a %b %e %H:%M:%S %Z %Y");
616 if (str[si] != fmt[fi])
627 while (isspace(str[si]))
633 if (str[si] != fmt[fi])
static long NUM2LONG(VALUE x)
#define rb_rational_new2(x, y)
size_t strlen(const char *)
void rb_backref_set(VALUE)
static const char * month_names[]
static VALUE INT2NUM(int v)
VALUE rb_backref_get(void)
#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 VALUE ULONG2NUM(unsigned long v)
static size_t date__strptime_internal(const char *str, size_t slen, const char *fmt, size_t flen, VALUE hash)
#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__strptime(const char *str, size_t slen, const char *fmt, size_t flen, VALUE hash)
VALUE date_zone_to_diff(VALUE)
VALUE rb_reg_nth_match(int, VALUE)