Allan Dyer wrote:
Hi

Thanks for creating an interesting package.

I'm trying to use DateTime::Calendar::Chinese to calculate public holidays for Hong Kong, as illustrated by this output from a test script, included below.

For 2004, Chinese New Year is 22 January, and there is a leap month after the
second lunar month. Buddah's Birthday is the 8th day of the 4th lunar month, so
(taking into account the leap month) that is 26 May. My script returns 26 April. Similarly, Tuen Ng is the 5th day of the 5th month, that is 22 June, but my script returns 23 May.


The table after "New Moons, Month starts" lists the dates of new moons, the first day of the month with leap_month => 0 and the first day of the month with
leap_month => 1. There is no difference between the last two columns: setting leap_month does nothing.

Well, the modules *does* look at the leap_month, but there's obviously something wrong if it's not making any difference in any of the dates calculated.


    my $prior_new_moon;
    if ($d->month == $self->month && $d->leap_month == $self->leap_month) {
        $prior_new_moon = $p;
    } else {
        $prior_new_moon = DateTime::Event::Lunar->new_moon_after(
            datetime    => $p + DateTime::Duration->new(days => 1),
            on_or_after => 1);
    }

I unfortunately don't have my copy of Calendrical Calculations with me right now so I can't double check, but I do admit there are cases where my code misses the dates somehow.... If you happen to be able to pin point a test case, pls let me know..

BTW

Base: 2004-01-01 00:00:00
Sui: 2004-01-22 12:00:00
Greg: 2004-01-22 12:00:00
New Moons, Month starts
2004-01-22 12:00:00 2004-02-20 00:00:00 2004-02-20 00:00:00

Oh shucks...


--d

Reply via email to