Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Support Era names #4591

Closed
eternalharvest opened this issue Apr 25, 2018 · 8 comments
Closed

[Feature request] Support Era names #4591

eternalharvest opened this issue Apr 25, 2018 · 8 comments

Comments

@eternalharvest
Copy link
Contributor

eternalharvest commented Apr 25, 2018

Description

In Japan, government agency and some company use traditional Japanese Imperial Calendar. But it seems moment.js is currently not supporting era names ~~~other than Christian Era~~~. So I want to write some patch to improve this. But I'm not familiar with this code-base. And I'm not sure whether if this can be done with unicode date format standard.

This feature is implemented as Era in Single Unix Specification (SU).
Please refer to the following link.
http://man7.org/linux/man-pages/man3/strftime.3.html

And java has same feature implemented in java.util.JapaneseImperialCalendar class though i don't like this implementation.

Regards.

Other information that may be helpful:

Related Issue

@eternalharvest
Copy link
Contributor Author

It seems Era names is not supported yet...

In LDML, 'GGGG' means Era name, but moment uses 'GGGG' format as 'ISO 4 digit week year'.
Should I define another symbol for implementing Era name support?

Related Issue

@eternalharvest eternalharvest changed the title [Feature request] Support Era names other than Christian Era [Feature request] Support Era names Apr 26, 2018
@icambron
Copy link
Member

Yeah, you'd need a new token. Probably anything unused is fine. Remember we can't do this unless we get eras for all the locales, so this is a big feature.

@eternalharvest
Copy link
Contributor Author

eternalharvest commented Apr 27, 2018

@icambron

Thank u for ur advice!

I think 'AC' and 'BC' is enough for almost all country (language).
So I am planning to introduce 'eras' field for mapping table in locale.
And if there is no 'eras' field in specific locale, fallback to use 'eras' mapping of 'en' locale.

Anyway, I'll try this.

@mattjohnsonpint
Copy link
Contributor

Note that the Japanese era name is planning to be changing on May 1, 2019 - and the new name is not yet chosen. Here's how Microsoft is handling this in Windows. Other applications that display era names may be taking a similar approach.

If we are to take this on in Moment, we should be prepared for an update.

@eternalharvest
Copy link
Contributor Author

eternalharvest commented May 10, 2018

@mj1856 As u mentioned, Japanese era name is planning to be changing on May 1, 2019.
As the link told me explains, Microsoft has added a registry so that it can respond instantly to updating the era.

On Linux, default definition of Japanese era is stored in /usr/share/i18n/locales/ja_JP.
And u can modify the original locale file or define custom locale using localedef command.

In my implementation in PR #4591, era name definitions are defined in locale of moment.js.
So, I think we can use Locale#updateLocale() directly or use Locale#defineLocale() to define new custom locale which inherit original locale to respond to the new era.

Microsoft implementation can respond to new era with a single registry entry.
In contrast, in my implementation we must redefine the whole era entries to respond to the new era.
But I think Microsoft implementation is too specialized into Japanese.

Please tell me if u have better idea which can respond to the new era.

@eternalharvest
Copy link
Contributor Author

@icambron, @mj1856

Although I know u are busy, but I would appreciate reviewing my PR!
And please tell me if I need update my PR.

Thanks u, and beast regards.

@ichernev
Copy link
Contributor

Close in favor of #4599

@robhatfield
Copy link

Why was this issue closed when the pull request has not been merged? Do you plan to merge in Japan imperial era support or not?

ichernev added a commit that referenced this issue Apr 27, 2020
[feature] Add era support for en,ja (closes #4591)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants