On Mon, 13 Dec 2004, Dave Rolsky wrote:

> On Mon, 13 Dec 2004, Tim Jenness wrote:
> 
> Yeah, I need to make that clearer.  The problem is that with leap seconds, 
> there are a few 3601 second hours out there.
> 

Now it becomes clear.

> > As a related aside. What is wrong with addiing 160.2 minutes to a DateTime
> > object? It seems to be a perfectly sensible thing to do if it is first
> > converted to seconds.
> 
> If you convert the .2 minutes to seconds first, yes, it is perfectly 
> sensible.
> 
> > Sorry to show my ignorance here but I am extremely confused by the fact
> > that I can't come up with any sane usage for a Duration object (I realise
> > that I'm probably being colored by assuming I can switch all my code from
> > Time::Seconds (part of Time::Piece) to DateTime::Duration with minimal
> > pain.
> 
> DT && DT::Duration are definitely not meant to emulate Time::Piece and 
> Time::Seconds.  Time::Seconds is intentionally bogus.  For example, it 
> assumes that each year has exactly 365.24225 days!
> 
> If you have data that assumes a 3600 second hour (for example TAI based 
> data), then you'd have to convert fractional minutes into minutes + 
> seconds before creating a new DT::Duration object.  This could be wrapped 
> up in a module easily.
> 

Yes. Okay, I finally understand where you are coming from.

Sometimes a duration really is a duration (essentially a number of 
seconds that can be represented in standardised days, minutes, hours). Or 
more explicitly, a stopwatch starts and then is stopped. The duration then 
has no concept of leap seconds, can not be rendered in units of 
months, since they vary in length, but can be rendered in standard years.

The leap second only becomes an issue when the duration is combined with 
a DateTime object. If it is a duration from a stopwatch then the real 
thing that matters is the number of seconds. If it is a duration 
consisting of discrete days, minutes, months, years and seconds then these 
have to be treated independently.

> Maybe it could be something like DT::Duration::Fractional?  What do others 
> think?

A variant of Duration that assumes standard lengths for day, minutes, hour 
etc, and with a caveat that it will always add seconds when combined with 
a DateTime object would be great.

Am I volunteering...?

-- 
Tim Jenness
JAC software
http://www.jach.hawaii.edu/~timj

Reply via email to