Skip Menu |

This queue is for tickets about the DateTime-Calendar-Japanese CPAN distribution.

Report information
The Basics
Id: 38692
Status: open
Priority: 0/
Queue: DateTime-Calendar-Japanese

People
Owner: Nobody in particular
Requestors: mskala [...] ansuz.sooke.bc.ca
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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.

Show quoted text
> 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.
This would only happen if the base calculations for chinese new years are different from expectation. Where is the source where you got the dates for lunar new year?
Subject: Re: [rt.cpan.org #38692] Bug: first year of era ends with Gregorian year
Date: Sun, 24 Aug 2008 18:51:06 -0400 (EDT)
To: Daisuke Maki via RT <bug-DateTime-Calendar-Japanese [...] rt.cpan.org>
From: mskala [...] ansuz.sooke.bc.ca
On Sun, 24 Aug 2008, Daisuke Maki via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=38692 > > >
> > 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.
> > This would only happen if the base calculations for chinese new years are > different from expectation. > Where is the source where you got the dates for lunar new year?
Those are the dates produced by DateTime::Calendar::Japanese, and I assumed the module was correct as far as that goes. That's not the point. The point is that it's incrementing the year on January 1 also, in addition to incrementing it on those dates. -- Matthew Skala mskala@ansuz.sooke.bc.ca Embrace and defend. http://ansuz.sooke.bc.ca/
Show quoted text
> Those are the dates produced by DateTime::Calendar::Japanese, and I > assumed the module was correct as far as that goes. That's not the > point. The point is that it's incrementing the year on January 1 > also, > in addition to incrementing it on those dates.
hmm, then _calc_era_components() is probably where the problem is. I haven't looked into it yet, and I don't think I'll have time until sometime next month. if you are willing to provide a patch, I'd appreciate it. thanks for the report.