New Japanese era in Linux

New Japanese era

On 1 May 2019 a new era of the Japanese calendar will begin. Fedora is ready for this change.

What This Is All About

1 December 2017 the Emperor of Japan Akihito officially announced that he would abdicate on 30 April 2019. From 1 May his successor Naruhito will rule which will also begin a new era in the Japanese calendar. This is rather unusual event because so far emperors ruled until their death. Obviously, this made the moment of the era change difficult to predict. The emperor’s decision will help the country prepare for the change.

Although the Gregorian calendar (the same as in many countries around the world) is known and used in Japan, the traditional Japanese calendar is also used with the years counted from the enthronement of an emperor. Each period of an emperor’s rule is called an era and has its own proper name. For example, the current era is named Heisei (平成), at the time of writing we have 31 year of Heisei era.

On 1 April, one month before the beginning of the new era its name was announced. It will be named Reiwa (令和). As we know it we can adapt computers and other devices displaying dates automatically.

How To Test

In Unix systems dates are formatted by strftime() function, the easiest way to test it is to use the date command. Launched from the command line it displays the current date and time in our own language and using the default format:

The change applies to the Japanese calendar which is available only in Japanese locales:

There is still nothing interesting because the default date format in Japanese locale displays the Gregorian calendar. A custom date format must be used:

So here we have something interesting: 31 year of Heisei era has been displayed.

So far we are in April, in the old Japanese era. How to display a date from the new era? Let’s use the commands which will display a date one month ahead:

If we still can see the 31 year of Heisei era then this is a bug. An updated system should display:

Why the command LC_ALL=ja_JP.utf8 date +%EY -d "1 month" has not displayed any number? The first year of an era usually is not written with a number 1 but described with a word gannen (元年) which means “the initial year”.

More Explanations

Let’s explain what those magical symbols like +%Ec mean. The character "+" means that the following string is a date format which has to be used. The character "%" marks the beginning of the format, the character "E" means that the alternative calendar should be used. Here is a summary of the format specifiers which have been used for tests:

%EC   the name of an era (e.g., Heisei, Reiwa)
%EY   year number including the era name
%Ey   year number in the Japanese calendar without an era name
%Ec   full date and time in the Japanese calendar
%Ex   full date (without the time) in the Japanese calendar

Compare this with:

%C   century number minus 1, or the initial digits of the year (currently 20—yes, not 21)
%Y   year number in the Gregorian calendar (2019)
%y   year number abbreviated to 2 digits (19)
%c   full date and time
%x   full date (without the time)

Please note that the "E" character in English locales will cause no effect, it will be ignored.

The -d switch means that date command should display a different date than the current one, for example -d "1 month" means one month ahead from now.

How To Update

In order that the calendar support the new Japanese era the glibc library must be updated to the version at least:

Fedora 28   glibc-2.27-38
Fedora 29   glibc-2.28-27
Fedora 30   glibc-2.29-9
Fedora Rawhide   glibc-2.29.9000-10
RHEL 7/CentOS 7   glibc-2.17-260.el7_6.4

Fedora Rawhide is a base for the future Fedora 31 release (November 2019) but before this happens a new version glibc 2.30 will be released which will support the new Japanese era from the beginning.

4 thoughts on “New Japanese era”

  1. Pingback: “On 1 May 2019 a new era of the Japanese calendar will begin. Fedor… | Dr. Roy Schestowitz (罗伊)

  2. Pingback: Links 18/4/2019: Ubuntu and Derivatives Have Releases, digiKam 6.1.0, OpenSSH 8.0 and LibreOffice 6.2.3 | Techrights

  3. I’m not Japanese but this is very interesting. It’s also interesting to see how it is solved. Thank you!

    1. Rafał Lużyński

      Thank you for your comment. Actually the solution was easy and the hardest part was to wait until the name of the new era is announced. If you are curious, most of the work behind can be found in swbz#22964. Links inside will guide you to actual commits. Then the patch had to be backported to Fedora because we don’t want to wait until August (glibc 2.30) and November (Fedora 31), this work was done as rhbz#1695404 (F28), rhbz#1696390 (F29), and rhbz#1696395 (F30).

Comments are closed.