mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parent
e2f987e654
commit
75fb0a9afa
2 changed files with 6 additions and 3 deletions
|
@ -2262,8 +2262,8 @@ iso8601_ext_datetime_cb(VALUE m, VALUE hash)
|
||||||
s[i] = rb_reg_nth_match(i, m);
|
s[i] = rb_reg_nth_match(i, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!NIL_P(s[3])) {
|
if (!NIL_P(s[1])) {
|
||||||
set_hash("mday", str2num(s[3]));
|
if (!NIL_P(s[3])) set_hash("mday", str2num(s[3]));
|
||||||
if (strcmp(RSTRING_PTR(s[1]), "-") != 0) {
|
if (strcmp(RSTRING_PTR(s[1]), "-") != 0) {
|
||||||
y = str2num(s[1]);
|
y = str2num(s[1]);
|
||||||
if (RSTRING_LEN(s[1]) < 4)
|
if (RSTRING_LEN(s[1]) < 4)
|
||||||
|
@ -2320,7 +2320,7 @@ static int
|
||||||
iso8601_ext_datetime(VALUE str, VALUE hash)
|
iso8601_ext_datetime(VALUE str, VALUE hash)
|
||||||
{
|
{
|
||||||
static const char pat_source[] =
|
static const char pat_source[] =
|
||||||
"\\A\\s*(?:([-+]?\\d{2,}|-)-(\\d{2})?-(\\d{2})|"
|
"\\A\\s*(?:([-+]?\\d{2,}|-)-(\\d{2})?(?:-(\\d{2}))?|"
|
||||||
"([-+]?\\d{2,})?-(\\d{3})|"
|
"([-+]?\\d{2,})?-(\\d{3})|"
|
||||||
"(\\d{4}|\\d{2})?-w(\\d{2})-(\\d)|"
|
"(\\d{4}|\\d{2})?-w(\\d{2})-(\\d)|"
|
||||||
"-w-(\\d))"
|
"-w-(\\d))"
|
||||||
|
|
|
@ -712,6 +712,9 @@ class TestDateParse < Test::Unit::TestCase
|
||||||
h = Date._iso8601('2001-02-03T04:05:06.07+01:00')
|
h = Date._iso8601('2001-02-03T04:05:06.07+01:00')
|
||||||
assert_equal([2001, 2, 3, 4, 5, 6, 3600],
|
assert_equal([2001, 2, 3, 4, 5, 6, 3600],
|
||||||
h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
|
h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
|
||||||
|
h = Date._iso8601('2001-02')
|
||||||
|
assert_equal([2001, 2],
|
||||||
|
h.values_at(:year, :mon))
|
||||||
|
|
||||||
h = Date._iso8601('010203T040506Z')
|
h = Date._iso8601('010203T040506Z')
|
||||||
assert_equal([2001, 2, 3, 4, 5, 6, 0],
|
assert_equal([2001, 2, 3, 4, 5, 6, 0],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue