Flavio S. Glock schreef:
> The first step would be to write to [EMAIL PROTECTED],
> in order to "register" your calendar in the
> "DateTime" namespace.
> It would probably be named "DateTime::Calendar::Jalali".

It looks like the Jalali calendar is also called the Persian calendar,
so DateTime::Calendar::Persian is a possibility too. I'm not familiar
with this calendar, its most common name, and the way it is used, so you
(Ahmad) should judge for yourself what name would be best.

I don't think there's anyone else working on this, so no problems there.

> Ahmad Anvari wrote:
> > Please send me the guidelines and standards and I'll
> > make Date::Jalali compatible with them so it can be
> > added to the project.

The most important point is that a DateTime::Calendar module does not
convert to Gregorian dates directly. Instead, it converts to a "day
count". Implement a _utc_rd_values() which returns this day count. For
the reverse conversion, write a from_object() method. The new() method
should accept Jalali dates only.

In the algorithm in Date::Jalali->new(), you do the conversion
Gregorian -> day count ($j_day_no, $g_day_no) -> Jalali. Remove the
first half, and you (almost) have your from_object(). (There probably is
an offset between "your" day count and "our" day count; it looks like
$g_day_no starts counting in 1600, while our "rata die" count starts in
1AD. Subtract an appropriate constant from the count before the conversion.)

See http://datetime.perl.org/developer/calendar.html for more
information. Ignore the time and timezone information for now (but it
would be nice to add time to your module in future, especially because
Jalali days apparently begin on noon instead of on midnight, and
Gregorian-Jalali date conversions therefore depend on the time of day...).

Perhaps the simplest example of an implementation of the conversion
methods is in my DateTime::Calendar::Pataphysical (see
http://search.cpan.org/src/PIJLL/DateTime-Calendar-Pataphysical-0.02/lib/DateTime/Calendar/Pataphysical.pm
for the source code).

By the way, do you know anything about the algorithm you're using? It
seems that the leap days are defined by astronomical observation (years
always start on the spring equinox in Teheran). There are several
algorithms to predict this day, but they are not perfect outside of a
certain time interval (see for example:
http://www.projectpluto.com/calendar.htm#jalali). Is there something like an "official 
algorithm"?

Eugene

Reply via email to