On Sat, 11 Oct 2003, Joshua Hoblitt wrote:

> DateTime::Duration should focus the Gregorian calendar.  There is no
> possible way to make it sufficiently generic to support all possible
> calendars without giving up functionality useful in it's intended
> context.  The best we should do to support alternate calendars is to
> implement a method that returns an absolute time interval in calendar
> independent units.

It did occur to me, however, that we could probably write a duration class
generator really easily.  Basically, durations are composed of base units
and derived units.  For the Gregorian/UTC system, the base units are
nanoseconds, seconds, minutes, days, and months.  The derived units are
hours (minutes * 60) and years (months * 12).

For the Hebrew calendar (which has no leap seconds), the base units are
nanoseconds, seconds, days, months, and years.  The derived units are
minutes and hours.

It'd be easy to have something like this:

 use DateTime::Duration::Generator
     ( base => [ qw( nanoseconds seconds minutes days months ) ],
       derived => { hours => [ 60 => minutes ],
                    years => [ 12 => months ],
                  },
     );

The only thing this doesn't handle is the end of month mode stuff.  But it
could easily generate the delta_* methods, the various unit methods, and
so on.


-dave

/*=======================
House Absolute Consulting
www.houseabsolute.com
=======================*/

Reply via email to