summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-04-09 01:27:36 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-04-09 01:27:36 +0000
commit320c98b436b5277678907b9ba32e4c6cdd3678a0 (patch)
tree9ede4685aca051866e93d82752675d9b956dfd39 /ext
parent63e66f08b6b524aff2bce99e30ef4fb343b2fe30 (diff)
date: support for Reiwa, new Japanese era
[Feature #15742] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/date/date_core.c6
-rw-r--r--ext/date/date_parse.c3
2 files changed, 7 insertions, 2 deletions
diff --git a/ext/date/date_core.c b/ext/date/date_core.c
index b6f806ff1f..67ed6171a7 100644
--- a/ext/date/date_core.c
+++ b/ext/date/date_core.c
@@ -7039,10 +7039,14 @@ jisx0301_date_format(char *fmt, size_t size, VALUE jd, VALUE y)
c = 'S';
s = 1925;
}
- else {
+ else if (d < 2458605) {
c = 'H';
s = 1988;
}
+ else {
+ c = 'R';
+ s = 2018;
+ }
snprintf(fmt, size, "%c%02ld" ".%%m.%%d", c, FIX2INT(y) - s);
return fmt;
}
diff --git a/ext/date/date_parse.c b/ext/date/date_parse.c
index 5bd10fb061..e0634c39f1 100644
--- a/ext/date/date_parse.c
+++ b/ext/date/date_parse.c
@@ -1212,7 +1212,7 @@ parse_iso2(VALUE str, VALUE hash)
return 1;
}
-#define JISX0301_ERA_INITIALS "mtsh"
+#define JISX0301_ERA_INITIALS "mtshr"
#define JISX0301_DEFAULT_ERA 'H' /* obsolete */
static int
@@ -1225,6 +1225,7 @@ gengo(int c)
case 'T': case 't': e = 1911; break;
case 'S': case 's': e = 1925; break;
case 'H': case 'h': e = 1988; break;
+ case 'R': case 'r': e = 2018; break;
default: e = 0; break;
}
return e;