Re: DateTime::Duration, length of a month?

2003-04-05 Thread Eugene van der Pijll
Joshua Hoblitt schreef:
 When converting a DateTime::Duration month to days - how many days
 should it be considering equivalent too? 30? 30.4? 31?

If you want to do this, you have to take into account that a duration of
$x years is translated to 12*$x years internally. If your calendar has
no months, it should calculate the number of days to add as

$delta_days + int( $delta_months * $DAYS_IN_YEAR/12 );

Problem with the Mayan calendar: it has no years either... But one of
the smaller counts (haab) is 365 days long, I believe. So that is
probably the Mayan idea of a year.

(As usual) I disagree with Dave: some people would find it useful to use
durations in any calendar, so why not implement them. As long as they
use days and years only, there is no problem. And if they try to add a
number of months to a Mayan date, they shouldn't complain about the
result.

Eugene


Re: DateTime::Duration, length of a month?

2003-04-05 Thread Rick Measham
At 12:05 PM +0200 5/4/03, Eugene van der Pijll wrote:
Problem with the Mayan calendar: it has no years either... But one of
the smaller counts (haab) is 365 days long, I believe. So that is
probably the Mayan idea of a year.
(As usual) I disagree with Dave: some people would find it useful to use
durations in any calendar, so why not implement them. As long as they
use days and years only, there is no problem. And if they try to add a
number of months to a Mayan date, they shouldn't complain about the
result.


Sure there should be Durations, but not DateTime::Durations. DateTime 
durations are based on the Gregorian Calendar. If you want to include 
durations they should be Mayan durations.

$mayan_duration = DateTime::Calendar::Mayan::Duration-new(
   baktuns=1,
   haabs = 8,
)
AFAICT there'd be no way to use -from_object unless you convert the 
::Mayan back into Gregorian, add/subtract the object, then convert it 
back into Mayan.

I imagine that on the whole Mayan will generally be used to convert 
from a DateTime into Mayan (and vice-versa). I don't think the call 
for inter-calendar durations will be too strong.

Cheers!
Rick
--

There are 10 kinds of people:
  those that understand binary, and those that don't.

  The day Microsoft makes something that doesn't suck
is the day they start selling vacuum cleaners

Write a wise proverb and your name will live forever.
   -- Anonymous



Re: DateTime::Duration, length of a month?

2003-04-05 Thread Yitzchak Scott-Thoennes
On Sat, 5 Apr 2003 12:05:15 +0200, [EMAIL PROTECTED] wrote:
Joshua Hoblitt schreef:
 When converting a DateTime::Duration month to days - how many days
 should it be considering equivalent too? 30? 30.4? 31?

If you want to do this, you have to take into account that a duration of
$x years is translated to 12*$x years internally. If your calendar has

 ^ assume you mean months here

no months, it should calculate the number of days to add as

$delta_days + int( $delta_months * $DAYS_IN_YEAR/12 );

Problem with the Mayan calendar: it has no years either... But one of
the smaller counts (haab) is 365 days long, I believe. So that is
probably the Mayan idea of a year.

(As usual) I disagree with Dave: some people would find it useful to use
durations in any calendar, so why not implement them. As long as they
use days and years only, there is no problem. And if they try to add a
number of months to a Mayan date, they shouldn't complain about the
result.

I think I wrote the part of Date::Ical that originally did the x years
= 12*x months translation, and I repent.  A duration object should
not merge its creating parameters into just seconds, days, and months
buckets.  This is much to Gregorian-centric.


DateTime::Duration, length of a month?

2003-04-04 Thread Joshua Hoblitt
When converting a DateTime::Duration month to days - how many days should it be 
considering equivalent too? 30? 30.4? 31?

-J

--