date_parse.c: extract Japanese era initials

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67397 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2019-04-01 05:21:36 +00:00
Родитель 367362b9d5
Коммит 744c314059
1 изменённых файлов: 5 добавлений и 3 удалений

Просмотреть файл

@ -1212,6 +1212,8 @@ parse_iso2(VALUE str, VALUE hash)
return 1;
}
#define JAPANESE_ERA_INITIALS "mtshr"
static int
gengo(int c)
{
@ -1252,11 +1254,11 @@ parse_jis(VALUE str, VALUE hash)
{
static const char pat_source[] =
#ifndef TIGHT_PARSER
"\\b([mtsh])(\\d+)\\.(\\d+)\\.(\\d+)"
"\\b([" JAPANESE_ERA_INITIALS "])(\\d+)\\.(\\d+)\\.(\\d+)"
#else
BOS
FPW_COM FPT_COM
"([mtsh])(\\d+)\\.(\\d+)\\.(\\d+)"
"([" JAPANESE_ERA_INITIALS "])(\\d+)\\.(\\d+)\\.(\\d+)"
TEE_FPT COM_FPW
EOS
#endif
@ -2979,7 +2981,7 @@ static int
jisx0301(VALUE str, VALUE hash)
{
static const char pat_source[] =
"\\A\\s*([mtsh])?(\\d{2})\\.(\\d{2})\\.(\\d{2})"
"\\A\\s*([" JAPANESE_ERA_INITIALS "])?(\\d{2})\\.(\\d{2})\\.(\\d{2})"
"(?:t"
"(?:(\\d{2}):(\\d{2})(?::(\\d{2})(?:[,.](\\d*))?)?"
"(z|[-+]\\d{2}(?::?\\d{2})?)?)?)?\\s*\\z";