Subject: | Bug: first year of era ends with Gregorian year |
Date: | Sun, 24 Aug 2008 10:07:31 -0400 (EDT) |
To: | bug-DateTime-Calendar-Japanese [...] rt.cpan.org |
From: | mskala [...] ansuz.sooke.bc.ca |
I'm using DateTime-Calendar-Japanese-0.06001 with perl v5.10.0 built for
i686-linux-ld; uname -a reports "Linux opal 2.6.19.1 #1 Tue Jan 9 20:55:16
EST 2007 i686 unknown".
It appears that for at least some and probably all historical eras,
conversion of dates from Gregorian to old-style Japanese produces the
wrong year-in-era numbers because DateTime::Calendar::Japanese incorrectly
increments the era year at the start of the first Gregorian year after the
start of the era, in addition to incrementing it correctly at each Lunar
New Year.
For instance, the Houei era started on 15 May 1704 Gregorian. The next
Lunar New Year was on 25 January 1705 Gregorian. Dates between those
should be part of Houei 1; dates from 25 January 1705 Gregorian until the
next Lunar New Year should be part of Houei 2.
Instead, the module reports 1 January 1705 Gregorian as the first day
of Houei 2, and then 25 January 1705 Gregorian as the first day of
Houei 3. This seems to be a consistent pattern for all the eras I've
tried: it increments from 1 to 2 at the start of the first Gregorian year
after the start of the era, and then increments at every Lunar New Year
thereafter. Year 1 should correctly be a short year because of eras
starting mid-year, but Year 2 should be a full-length year, and in this
case it's just 24 days.
The attached code demonstrates the problem.
I am not sure whether it affects all eras, but it seems to affect all the
ones I've tested. The practical result is that the module's
output is nearly always incorrect.
On examining the tests for this module I note that only dates in the (most
recent) Shouwa and Heisei eras are ever tested. Since this calendar was
not in use during those eras anyway, they are probably not good inputs
for testing the code.
--
Matthew Skala
mskala@ansuz.sooke.bc.ca Embrace and defend.
http://ansuz.sooke.bc.ca/
Message body is not shown because sender requested not to inline it.