Bug #12833 ยป iso8601_YYYY_MM.patch
ext/date/date_parse.c | ||
---|---|---|
set_hash("mon", str2num(s[2]));
|
||
}
|
||
else if (!NIL_P(s[5])) {
|
||
set_hash("yday", str2num(s[5]));
|
||
if (RSTRING_LEN(s[5]) > 2) {
|
||
set_hash("yday", str2num(s[5]));
|
||
} else {
|
||
set_hash("month", str2num(s[5]));
|
||
}
|
||
if (!NIL_P(s[4])) {
|
||
y = str2num(s[4]);
|
||
if (RSTRING_LEN(s[4]) < 4)
|
||
... | ... | |
{
|
||
static const char pat_source[] =
|
||
"\\A\\s*(?:([-+]?\\d{2,}|-)-(\\d{2})?-(\\d{2})|"
|
||
"([-+]?\\d{2,})?-(\\d{3})|"
|
||
"([-+]?\\d{2,})?-(\\d{2,3})|"
|
||
"(\\d{4}|\\d{2})?-w(\\d{2})-(\\d)|"
|
||
"-w-(\\d))"
|
||
"(?:t"
|
test/date/test_date_parse.rb | ||
---|---|---|
h = Date._iso8601('2001-023T04:05:06Z')
|
||
assert_equal([2001, 23, 4, 5, 6, 0],
|
||
h.values_at(:year, :yday, :hour, :min, :sec, :offset))
|
||
h = Date._iso8601('2001-23')
|
||
assert_equal([2001, 23],
|
||
h.values_at(:year, :month))
|
||
h = Date._iso8601('-023T04:05:06Z')
|
||
assert_equal([nil, 23, 4, 5, 6, 0],
|
||
h.values_at(:year, :yday, :hour, :min, :sec, :offset))
|