summaryrefslogtreecommitdiff
path: root/ext/date
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-07-16 09:30:58 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-07-16 09:41:23 +0900
commit75fb0a9afad1685cedee9c7665a7f30ec95068fc (patch)
tree1e5a9f3ca2389904ab99c301e6ac8e3f1ea27dab /ext/date
parente2f987e65461bff85be2146dda93655b7d13a537 (diff)
Allow mday in Date.iso8601 to be omitted
[Bug #12285]
Diffstat (limited to 'ext/date')
-rw-r--r--ext/date/date_parse.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/ext/date/date_parse.c b/ext/date/date_parse.c
index e0634c39f1..ab46bda4ad 100644
--- a/ext/date/date_parse.c
+++ b/ext/date/date_parse.c
@@ -2262,8 +2262,8 @@ iso8601_ext_datetime_cb(VALUE m, VALUE hash)
s[i] = rb_reg_nth_match(i, m);
}
- if (!NIL_P(s[3])) {
- set_hash("mday", str2num(s[3]));
+ if (!NIL_P(s[1])) {
+ if (!NIL_P(s[3])) set_hash("mday", str2num(s[3]));
if (strcmp(RSTRING_PTR(s[1]), "-") != 0) {
y = str2num(s[1]);
if (RSTRING_LEN(s[1]) < 4)
@@ -2320,7 +2320,7 @@ static int
iso8601_ext_datetime(VALUE str, VALUE hash)
{
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{4}|\\d{2})?-w(\\d{2})-(\\d)|"
"-w-(\\d))"