Add support for Japanese calendar, and clean up other calendar routines
to use some common functions.