Re: More flexibly subtract/difference methods

2003-10-11 Thread Eric Cholet
Matt Sisk wrote: Dave Rolsky wrote: Currently, the default when subtracting datetimes is to break down the duration into multiple parts, months, days, minutes, seconds, and nanoseconds. From the months piece we can derive years, and from the days piece we can derive weeks. Rick Measham

Re: More flexibly subtract/difference methods

2003-10-11 Thread Dave Rolsky
On Fri, 11 Oct 2003, Rick Measham wrote: But some people have indicated that they'd like something a little more flexible. Eugene van der Pijll suggested something like this: my $dur = $dt1-difference( datetime = $dt2, units= [ 'months', 'days' ] );

Re: More flexibly subtract/difference methods

2003-10-11 Thread Dave Rolsky
On Fri, 10 Oct 2003, Flavio S. Glock wrote: That's true, because you are talking about a DateTime.pm method. (delta_ymd would make sense in other calendars, that don't have exactly 12 months.) However, if DT::Duration is given 'year' units, it should not automatically convert it to months,

Re: More flexibly subtract/difference methods

2003-10-11 Thread Joshua Hoblitt
However, if DT::Duration is given 'year' units, it should not automatically convert it to months, because I may want to use that information in a non-gregorian context. Well, you might, but you can't ;) I agree completely. Seriously, I think this idea that DateTime::Duration should work

Re: More flexibly subtract/difference methods

2003-10-11 Thread Dave Rolsky
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

DateTime from Rata Die?

2003-10-11 Thread Daisuke Maki
I was trying to fool around with some calculations from Calendrical Calculations -- one of the tables in there shows values corresponding to Rata Die dates, and I was trying to see if DateTime supported creating DateTime objects from Rata Die values... I didn't see one, so I guess it doesn't. Is

Re: DateTime from Rata Die?

2003-10-11 Thread Daisuke Maki
Bah, answering my question... my $rata_die = DateTime-new(year = 1, month = 1, day = 1); my $from_rd = $rata_die + DateTime::Duration-new(days = $rd_days); --d I was trying to fool around with some calculations from Calendrical Calculations -- one of the tables in there shows values

Re: DateTime from Rata Die?

2003-10-11 Thread Dave Rolsky
On Sat, 11 Oct 2003, Daisuke Maki wrote: Bah, answering my question... my $rata_die = DateTime-new(year = 1, month = 1, day = 1); my $from_rd = $rata_die + DateTime::Duration-new(days = $rd_days); That works, as does: { package DateTime::RataDie; sub utc_rd_values { @{$_[0]} } }

[Kinda OT] Could somebody double check this?

2003-10-11 Thread Daisuke Maki
Hi, dt-ers. I've been lurking on this list for some time now, and so far I understand that while a few people have attempted, nobody has come up with a lunar, solar, or lunisolar calenders (at least I don't remember seeing it on this list). And so I was just fooling around with some code to see

Re: DateTime from Rata Die?

2003-10-11 Thread fglock
A shorter one: --- my $from_rd = DateTime-new(year = 1)-add(days = $rd_days); --- A shorter class for Dave's program: --- sub DateTime::RataDie::utc_rd_values { @{$_[0]} } --- - Flavio S. Glock