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
ICU-12973 CLDR Japanese Era data and tentative Japanese new era support #111
Conversation
…from CLDR data in ICU4J.
Also added API comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
era rules in C LGTM
icu4c/source/i18n/erarules.cpp
Outdated
|
||
EraRules* EraRules::createInstance(const char *calType, UBool includeTentativeEra, UErrorCode& status) { | ||
if(U_FAILURE(status)) { | ||
return NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Can we use nullptr
since this is C++ file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK C++11 :) I'll update.
icu4c/source/i18n/erarules.cpp
Outdated
if(U_FAILURE(status)) { | ||
return NULL; | ||
} | ||
UResourceBundle *rb = ures_openDirect(NULL, "supplementalData", &status); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Could use LocalUResourceBundlePointer
for this, so don't need to clean-up manually. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see - will do.
icu4c/source/i18n/erarules.cpp
Outdated
int32_t firstTentativeIdx = MAX_INT32; | ||
|
||
int32_t *startDates = (int32_t*)uprv_malloc(numEras * sizeof(int32_t)); | ||
if (startDates == NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nullptr
// By default, such tentative era is disabled. | ||
|
||
// 1. Environment variable ICU_ENABLE_TENTATIVE_ERA=true or false | ||
// 2. Windows registry (TBD) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yumaoka It might also be possible to check for environment variable in UWP as well.
Once this PR is in, perhaps I can also make another PR for this? (After the IUC 42 though).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I investigated quickly, but could not find it. I appreciate you can work on it.
- NULL to nullptr - use of LocalUResourceBundlePointer - TYPO "name" to "named" - env var checking stricmp() == 0
@jefgen I updated ICU4C implementation based on your comments. Also a few bug fixes. Please review it again. #Closed |
as of 3b01ed4 the tentative formatting works and is selectable. 👍
|
icu4c/source/i18n/unicode/ucal.h
Outdated
* <p> | ||
* The Japanese calendar uses a combination of era name and year number. | ||
* When an empror of Japan abdicates and a new emperor ascends the throne, | ||
* a new era is declared and year number is reset to 1. Even the date of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: wording. Perhaps use this: "Even [if] the date of"
int32_t numEras = ures_getSize(rb.getAlias()); | ||
int32_t firstTentativeIdx = MAX_INT32; | ||
|
||
int32_t *startDates = (int32_t*)uprv_malloc(numEras * sizeof(int32_t)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: could probably use LocalPointer instead of uprv_malloc. but I don't think this is necessary for now. I can change this later when adding UWP env support.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks Yoshito.
Also, duplicate the comment in ucal.h to calendar.h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm with minor
} | ||
|
||
void EraRulesTest::testJapanese() { | ||
const int32_t HEISEI = 235; // ICU4C does not define constants for eras |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not ideal, but probably fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ICU4J exposes some constants for modern eras as int. Heisei is currently 235. ICU4J document says it might be changed in new releases. Markus pointed out it's not a good idea to change the value of these constants.
In this release, I considered that we clearly state these constant values won't change in future releases. But at the same time, I really think we should drop era data before Meiji. This would change the era indexes one more time.
I think it's not too late to find out how to expose some Japanese era constants after we decide what to do with historic eras.
} | ||
|
||
void EraRulesTest::testAPIs() { | ||
const char * calTypes[] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no other way to iterate on these types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ICU4J has CalType enum. ICU4C has calendar type enum, but their names are defined in calendar.cpp (https://github.com/unicode-org/icu/blob/master/icu4c/source/i18n/calendar.cpp#L159) and has no API exposed to get calendar type name from enum or vise versa.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -634,6 +414,7 @@ protected int handleGetLimit(int field, int limitType) { | |||
* {@inheritDoc} | |||
* @stable ICU 3.8 | |||
*/ | |||
@Override | |||
public String getType() { | |||
return "japanese"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CalType.JAPANESE.name()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. If I remember correctly, getType() was implemented before CalType enum.
I did not touch this method for this time - eclipse kindly :) supplied @Override
annotation automatically when saving JapaneseCalendar.java changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other calendars have the same issue. I'd want to make consistent change with the new ticket https://unicode-org.atlassian.net/projects/ICU/issues/ICU-20134
On Windows, with the Win32 version of ICU4C (UWP is yet to come) using a modified date program (Console is UTF-8 code-page).
|
…rt (unicode-org#111) * Updated era data format in supplementalData. * Include tentative era names in data. Implemented Japanese era loaded from CLDR data in ICU4J. * ICU4C implementation, ICU4C refactoring. WIP. * VS project updates and some bug fixes Also added API comments. * Review feedback and bug fixes - NULL to nullptr - use of LocalUResourceBundlePointer - TYPO "name" to "named" - env var checking stricmp() == 0 * API comment correction based on feedback * Duplicate the comment in ucal.h to calendar.h * Fixed spelling errors in API comment
…rt (unicode-org#111) * Updated era data format in supplementalData. * Include tentative era names in data. Implemented Japanese era loaded from CLDR data in ICU4J. * ICU4C implementation, ICU4C refactoring. WIP. * VS project updates and some bug fixes Also added API comments. * Review feedback and bug fixes - NULL to nullptr - use of LocalUResourceBundlePointer - TYPO "name" to "named" - env var checking stricmp() == 0 * API comment correction based on feedback * Duplicate the comment in ucal.h to calendar.h * Fixed spelling errors in API comment
…rt (unicode-org#111) * Updated era data format in supplementalData. * Include tentative era names in data. Implemented Japanese era loaded from CLDR data in ICU4J. * ICU4C implementation, ICU4C refactoring. WIP. * VS project updates and some bug fixes Also added API comments. * Review feedback and bug fixes - NULL to nullptr - use of LocalUResourceBundlePointer - TYPO "name" to "named" - env var checking stricmp() == 0 * API comment correction based on feedback * Duplicate the comment in ucal.h to calendar.h * Fixed spelling errors in API comment
…rt (unicode-org#111) * Updated era data format in supplementalData. * Include tentative era names in data. Implemented Japanese era loaded from CLDR data in ICU4J. * ICU4C implementation, ICU4C refactoring. WIP. * VS project updates and some bug fixes Also added API comments. * Review feedback and bug fixes - NULL to nullptr - use of LocalUResourceBundlePointer - TYPO "name" to "named" - env var checking stricmp() == 0 * API comment correction based on feedback * Duplicate the comment in ucal.h to calendar.h * Fixed spelling errors in API comment
…rt (unicode-org#111) * Updated era data format in supplementalData. * Include tentative era names in data. Implemented Japanese era loaded from CLDR data in ICU4J. * ICU4C implementation, ICU4C refactoring. WIP. * VS project updates and some bug fixes Also added API comments. * Review feedback and bug fixes - NULL to nullptr - use of LocalUResourceBundlePointer - TYPO "name" to "named" - env var checking stricmp() == 0 * API comment correction based on feedback * Duplicate the comment in ucal.h to calendar.h * Fixed spelling errors in API comment
…rt (unicode-org#111) * Updated era data format in supplementalData. * Include tentative era names in data. Implemented Japanese era loaded from CLDR data in ICU4J. * ICU4C implementation, ICU4C refactoring. WIP. * VS project updates and some bug fixes Also added API comments. * Review feedback and bug fixes - NULL to nullptr - use of LocalUResourceBundlePointer - TYPO "name" to "named" - env var checking stricmp() == 0 * API comment correction based on feedback * Duplicate the comment in ucal.h to calendar.h * Fixed spelling errors in API comment
…rt (unicode-org#111) * Updated era data format in supplementalData. * Include tentative era names in data. Implemented Japanese era loaded from CLDR data in ICU4J. * ICU4C implementation, ICU4C refactoring. WIP. * VS project updates and some bug fixes Also added API comments. * Review feedback and bug fixes - NULL to nullptr - use of LocalUResourceBundlePointer - TYPO "name" to "named" - env var checking stricmp() == 0 * API comment correction based on feedback * Duplicate the comment in ucal.h to calendar.h * Fixed spelling errors in API comment
… the New Era. Manually cherry-picked from commit: 45cdda6 Original commit message: ICU-12973 CLDR Japanese Era data and tentative Japanese new era support (unicode-org#111) * Updated era data format in supplementalData. * Include tentative era names in data. Implemented Japanese era loaded from CLDR data in ICU4J. * ICU4C implementation, ICU4C refactoring. WIP. * VS project updates and some bug fixes Also added API comments. * Review feedback and bug fixes - NULL to nullptr - use of LocalUResourceBundlePointer - TYPO "name" to "named" - env var checking stricmp() == 0 * API comment correction based on feedback * Duplicate the comment in ucal.h to calendar.h * Fixed spelling errors in API comment
… the New Era. Manually cherry-picked from commit: 45cdda6 Original commit message: ICU-12973 CLDR Japanese Era data and tentative Japanese new era support (unicode-org#111) * Updated era data format in supplementalData. * Include tentative era names in data. Implemented Japanese era loaded from CLDR data in ICU4J. * ICU4C implementation, ICU4C refactoring. WIP. * VS project updates and some bug fixes Also added API comments. * Review feedback and bug fixes - NULL to nullptr - use of LocalUResourceBundlePointer - TYPO "name" to "named" - env var checking stricmp() == 0 * API comment correction based on feedback * Duplicate the comment in ucal.h to calendar.h * Fixed spelling errors in API comment
… the New Era. Manually cherry-picked from commit: 45cdda6 Original commit message: ICU-12973 CLDR Japanese Era data and tentative Japanese new era support (#111) * Updated era data format in supplementalData. * Include tentative era names in data. Implemented Japanese era loaded from CLDR data in ICU4J. * ICU4C implementation, ICU4C refactoring. WIP. * VS project updates and some bug fixes Also added API comments. * Review feedback and bug fixes - NULL to nullptr - use of LocalUResourceBundlePointer - TYPO "name" to "named" - env var checking stricmp() == 0 * API comment correction based on feedback * Duplicate the comment in ucal.h to calendar.h * Fixed spelling errors in API comment
Note: Other calendar implementation classes may also use EraRules, but it may not add much values. For now, CLDR era data is utilized only by Japanese calendar.
Checklist