Re: DateTime::Duration 'in_units' does not properly normalize units

2004-12-13 Thread Dave Rolsky
On Mon, 13 Dec 2004, Joshua Hoblitt wrote: It looks like the normalization is hosed. This method, for the nth time, does not convert between units which do not have a fixed conversion rate. I'd also point out that it probably won't work well with non-integer units. I'm not sure what'll happen

Re: DateTime::Duration 'in_units' does not properly normalize units

2004-12-13 Thread Tim Jenness
Dave, Thanks for the reply. So are you saying that DateTime::Duration shouldn't really be used at all if I have units of fractional anything and want to convert that to a duration? I'm supposed to convert it first to hours, minutes and seconds and then instantiate a DateTime::Duration from

Re: DateTime::Duration 'in_units' does not properly normalize units

2004-12-13 Thread Tim Jenness
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

Re: DateTime::Duration 'in_units' does not properly normalize units

2004-12-13 Thread fglock
I once wrote a module to do this (long before DateTime). Note that in the second case the result is exact. Date::Tie is _very_ careful to round errors correctly. use Date::Tie; tie my %date, 'Date::Tie', frac_hour = 2.67; print $date{frac_hour}, \n; print $date{hour}, :,

DateTime::Duration 'in_units' does not properly normalize units

2004-12-13 Thread Joshua Hoblitt
Hi Tim, It looks like the normalization is hosed. Cut 'n Paste-able example: -- use DateTime::Duration; my $dur = DateTime::Duration-new( hours = 2.67 ); print hours: ,$dur-in_units( 'hours' ), \n; print minutes: , $dur-in_units( 'minutes' ), \n; print seconds: , $dur-in_units(

Re: DateTime::Duration 'in_units' does not properly normalize units

2004-12-13 Thread Dave Rolsky
On Mon, 13 Dec 2004, Dave Rolsky wrote: How can that be sane? So you ask for minutes and you get fractional minutes but you ask for seconds and get zero? Cause really it should just blow up when you give it fractional anything. Or not. Anyone know of a good way to check that a parameter is one

Re: DateTime::Duration 'in_units' does not properly normalize units

2004-12-13 Thread Yitzchak Scott-Thoennes
On Mon, Dec 13, 2004 at 07:04:23PM -0600, Dave Rolsky [EMAIL PROTECTED] wrote: On Mon, 13 Dec 2004, Dave Rolsky wrote: How can that be sane? So you ask for minutes and you get fractional minutes but you ask for seconds and get zero? Cause really it should just blow up when you give it

Re: DateTime::Duration 'in_units' does not properly normalize units

2004-12-13 Thread Dave Rolsky
On Mon, 13 Dec 2004, Tim Jenness wrote: Thanks for the reply. So are you saying that DateTime::Duration shouldn't really be used at all if I have units of fractional anything and want to convert that to a duration? I'm supposed to convert it first to hours, minutes and seconds and then

Re: DateTime::Duration 'in_units' does not properly normalize units

2004-12-13 Thread Joshua Hoblitt
On Mon, 13 Dec 2004, Dave Rolsky wrote: On Mon, 13 Dec 2004, Joshua Hoblitt wrote: It looks like the normalization is hosed. This method, for the nth time, does not convert between units which do not have a fixed conversion rate. Whooo, I seem to have missed the bus here. Wasn't the entire point

Re: DateTime::Duration 'in_units' does not properly normalize units

2004-12-13 Thread Joshua Hoblitt
On Mon, 13 Dec 2004, Tim Jenness wrote: On Mon, 13 Dec 2004, Dave Rolsky wrote: 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

Re: DateTime::Duration 'in_units' does not properly normalize units

2004-12-13 Thread Yitzchak Scott-Thoennes
On Mon, Dec 13, 2004 at 06:14:12PM -0800, Yitzchak Scott-Thoennes [EMAIL PROTECTED] wrote: On Mon, Dec 13, 2004 at 07:04:23PM -0600, Dave Rolsky [EMAIL PROTECTED] wrote: On Mon, 13 Dec 2004, Dave Rolsky wrote: How can that be sane? So you ask for minutes and you get fractional minutes

Re: DateTime::Duration 'in_units' does not properly normalize units

2004-12-13 Thread Dave Rolsky
On Mon, 13 Dec 2004, Joshua Hoblitt wrote: On Mon, 13 Dec 2004, Dave Rolsky wrote: On Mon, 13 Dec 2004, Joshua Hoblitt wrote: It looks like the normalization is hosed. This method, for the nth time, does not convert between units which do not have a fixed conversion rate. Whooo, I seem to have