Skip to content

tokyo-rubyist-meetup/pair-programming-1b

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Oct 18, 2012
82a4062 · Oct 18, 2012

History

1 Commit
Oct 18, 2012

Repository files navigation

Japanese Era Calendar Scheme

If you've ever had to fill out paperwork in Japan, you know that the country uses two systems for counting dates: the western Gregorian calendar, and the Japanese era calendar scheme, which uses the combination of the reigning Emperor's name and year since his birth.

Write a program that takes a Gregorian date as an input, give the Japanese era date as an output. For example, with 2012-10-20 as an input, the output would be 平成24年10月20日.

To get you started, I've reproduced part of a table of era information.

年号 西暦 改元日 備考
明治 1868~1912 9/8 明治元年は1/1から。明治6年以降は太陽暦
大正 1912~1926 7/30
昭和 1926~1989 12/25 昭和64年は1月7日まで
平成 1989~ 1/8
  • 明治5年12月2日まで太陰太陽暦(旧暦)を使用。
  • 明治5年11月9日の「太政官布告」により、太陽暦(グレゴリオ暦)に改暦され、「明治5年12月2日」の翌日が「明治6年1月1日」。 「明治改元の布告」、大正や昭和の「改元の詔書」によると 明治改元の詔書が出されたのは慶応4年9月8日だが、明治元年は「1月1日」から、即ち9月8日まで」は慶応4年でも明治元年でも。「明治45年7月30日」と「大正元年7月30日」及び「大正15年12月25日」と「昭和元年12月25日」は、ともに存在。
  • 「元号を改める政令(昭和64年1月7日)」によると  昭和64年は「1月7日」までで、平成元年は「1月8日」から。

Extensions

Once you've completed the above, try out some of the following extensions.

All the eras

The first Japanese era started in 645. Take a look at the table of era information, and see if you can cover all of them.

Kanji Numerals

Write your dates only using Kanji! For instance, 2012-10-20 becomes 平成二十四年十月二十日.

Pronunciation of Dates

Have an option to output the reading of the dates. For instance, 2012-10-20 becomes へいせいにじゅうねんじゅうがつはつか.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published