Japanese Calendars, How do I Test Support for Additional Eras?

The Japanese Calendar is labeled by the reign of the current emporer.  Windows has supported 4 Japanese calendar Eras, however in the future there may be more eras.  Realizing this, we've added support in Windows 7, Server 2008R2 & .Net v4 for additional Japanese Eras.

There're a few things applications should know about extended Japanese Era support:

  • The first is that applications may see more than 4 eras!.
  • The current era could end
  • Future dates could change, moving from the current era to a new era.  (So "Heisei 71" could be "something 12" or something like that)
  • The era numbers themselves could change, so the 1-4 era numbers shouldn't be relied upon.

Cool, so if we're being careful about all of those things, and are pretty sure we don't have any hard-coded dependencies on the Japanese Eras or when they are, how do we test it?

On Windows 7 / Server 2008 R2 (beta) and CLRv4 (beta) Japanese era information can be found in the registry:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\Calendars\Japanese\Eras]
"1868 01 01"="明治_明_Meiji_M"
"1912 07 30"="大正_大_Taisho_T"
"1926 12 25"="昭和_昭_Showa_S"
"1989 01 08"="平成_平_Heisei_H"

Additional eras can be added just by adding an entry to the table.  The format for the value "YYYY MM DD"="JE_AJE_EE_AEE" where the first day of the era is represented in the value name by YYYY for the year (gregorian), MM for the month, and DD for the day.  The value data contains the era strings, the "full" era name, followed by the abbreviated name (in Japanese), then the full name followed by the abbreviated name in English.  Each value is seperated by _ (underscore).  So in "YYYY MM DD"="JE_AJE_EE_AEE", JE represents the Japanese Era name, AJE represents the abbreviated Japanese Era.  EE represents the English Era name, and AEE represents the abbreviated English Era name.

An example would be:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\Calendars\Japanese\Eras]
"1868 01 01"="明治_明_Meiji_M"
"1912 07 30"="大正_大_Taisho_T"
"1926 12 25"="昭和_昭_Showa_S"
"1989 01 08"="平成_平_Heisei_H"
"20219 05 01"="仮名_仮_Test Era_X"

(I'm not trying to make any predictions with the 2019, it's just a test number :)  Also remember this only works in Windows 7 and other newer products.

[Edited:  This is intended to support the possibility of a future era, not to enable older eras.  There's the potential that lots of stuff won't work correctly if eras prior to the existing 4 are added].  Also note that this registry key is pretty flexible.  If you want you could add a bunch of data for a bunch of eras < 1868.  (I don't have the data.)  That might break more stuff because then "Era 1" would turn into "Era 8" or something.  (Which is why I said not to depend on the Era number, it's pretty meaningless and arbitrary for us).  As noted, we only really intended to support adding new eras, not the historical ones.  Prior to 1870 or so the calendar was lunar not gregorian based, so conversions prior to then are pretty meaningless anyway.

 

Hope this is interesting,

 

Shawn