Let's display the Japanese calendar in Python! I thought. For example, 2015. I especially want to display my birthday in the Japanese calendar.
When I looked it up, it seems that there is locale.ERA
in the standard, but if it is Japan or something like strfprint
, it will be displayed as H27! It says, but I can't find anything that corresponds to the strfprint
format.
So, I wondered what happened to other languages, and when I looked up Ruby, era_ja was convenient.
On the other hand, it seems that there is no Python version, so I thought I would make it, and I made erajp. (I felt that Japanese was ja and Japan was jp, so I chose jp)
https://github.com/recruit-mtl/erajp
Well, it's not a big deal to do, and I was able to refer to era_ja a lot.
I wrote a test using nose on Travis CI, made it work, displayed coverage using Coveralls, registered it on PyPI and installed it with pip, and so on. Was funny.
By the way, you can use it like this.
>>> strjpftime()
'H27.08.05' # now
>>> strjpftime(datetime.datetime(1989, 1, 8))
'H1.01.08'
>>> strjpftime(datetime.datetime(1989, 1, 8), u"%O%Year E")
'1989'
Recommended Posts