Support Short Japanese Era Name
Hi,
To put a little bit of context, japanese dates can be written using the imperial calendar. The current Japanese era is Reiwa. It is written 令和 and can be abbreviated 令 or R. For instance 令和2年1月1日 which stands for january 1st of the 2th year of 令和 era, can also be abbreviated 令2年1月1日 or R2.1.1
Since moment 2.25, it is possible to extract japanese dates using era notation.
| Code | Result |
|---|---|
| moment("令和2年1月1日", "NNNNyoM月D日", "ja").format('YYYY-MM-DD') | "2020-01-01" |
| moment("R2.1.1", "Ny.M.D", "ja").format('YYYY-MM-DD') | "2020-01-01" |
But, it is not possible to parse "令2年1月1日", because there is no token for this abbreviation. Tokens N, NN and NNN are all linked to the property eraAbbr which is R for the current japanese Reiwa era. And NNNN is for 令和.
By the way, the documentation does not describe the current implementation. https://momentjs.com/docs/#/parsing/string-format/ It is written
| Input | Examples | Description |
|---|---|---|
| N | AD | Abbr Era name |
| NN | AD | Short Era name |
| NNN | Anno Domini | Full Era name |
The documentation description would be great. That also would correlate to the LibreOffice tokens
| Input | Result |
|---|---|
| GGGE | 令和 |
| GGE | 令 |
| GE | R |
Thanks
Source: moment/moment