Re: Re: DT::Duration overloads
On 6/11/04 Rick Measham wrote: >On Thu, 10 Jun 2004 [EMAIL PROTECTED] wrote: >> How about a DateTime::Span->midpoint method? > >On 11 Jun 2004, at 6:55 AM, Dave Rolsky replied: >> Let's wait and see if others ask for it. For now, let's just >>add those recipes to the faq. > >I'm not sure of the best namespace, but I can see a Util namespace >would be a good place for FRSs (Frequently Required Solutions) Flavio's solutions are brief and efficient. Why not just have it in the FAQ, as Dave suggests? > use DateTime::Util::Stats qw/:all/; > # Solar Noon is the mean of sunrise and sunset: > my $mean = mean_datetime( @dt_list ) > # The mean is: round(scalar(@_) + 1 / 2) # IIRC > # therefore $median == $sunset > my $median = median_datetime( @dt_list ) > >On the other hand, maybe these should be DateTime::Set methods: > my $mean = $set->mean( $sunrise, $sunset ); > my $median = $set->median( $sunrise, $sunset ); Huh? I'm confused by your usage of 'mean' and 'median'. In the case in question, I think 'midpoint' is a much clearer term to use. My $.02. 1; - Bruce __bruce__van_allen__santa_cruz__ca__
Re: Re: DT::Duration overloads
On Thu, 10 Jun 2004 [EMAIL PROTECTED] wrote: How about a DateTime::Span->midpoint method? On 11 Jun 2004, at 6:55 AM, Dave Rolsky replied: Let's wait and see if others ask for it. For now, let's just add those recipes to the faq. I'm not sure of the best namespace, but I can see a Util namespace would be a good place for FRSs (Frequently Required Solutions) use DateTime::Util::Stats qw/:all/; # Solar Noon is the mean of sunrise and sunset: my $mean = mean_datetime( @dt_list ) # The mean is: round(scalar(@_) + 1 / 2) # IIRC # therefore $median == $sunset my $median = median_datetime( @dt_list ) On the other hand, maybe these should be DateTime::Set methods: my $mean = $set->mean( $sunrise, $sunset ); my $median = $set->median( $sunrise, $sunset ); I'm not sure that DateTime::Span is a good place for these as it would only apply to getting the mean of two DateTime objects whereas in DateTime::Set it's scope increases to allow any number of DateTimes. Would/Could there be any use for other statistical functions such as Standard Deviations? I can't think of any possible need for StdDev at the moment, but maybe there getting rid of outliers will be of benefit to someone? Cheers! Rick Senior Developer PrintSupply - Print Procurement & Supply Management 18 Greenaway Street VIC 3105 Tel: (03) 9850 3255 Fx: (03) 9850 3277 http://www.printsupply.com.au/
ANNOUNCE: DateTime.pm 0.2101
0.2101 2004-06-10 - There was a bug in the date math code that occurred if you tried to add enough days, minutes or seconds to generate a datetime 10 years in the future (or so). If the the DateTime object had a a time zone with recurring DST changes, then the date math operation would cause a fatal error "Invalid local time for date in time zone ...". Reported by Dave Faraldo. -dave /*=== House Absolute Consulting www.houseabsolute.com ===*/
Re: DT::Duration overloads
On Thu, 10 Jun 2004 [EMAIL PROTECTED] wrote: > Matt Sisk wrote: > > what is the midpoint of a span? > > With DateTime::Span: > > $mid_point = > $span->start->add_duration( > seconds => $span->duration->seconds / 2 > ); > > With DateTime: > > $mid_point = > $start->add_duration( > seconds => $end->subtract_datetime_absolute( > $start > )->seconds / 2 > ); Oh, duh! Why didn't I think of that. That's nice & simple. > How about a DateTime::Span->midpoint method? Let's wait and see if others ask for it. For now, let's just add those recipes to the faq. -dave /*=== House Absolute Consulting www.houseabsolute.com ===*/
Re: DT::Duration overloads
Matt Sisk wrote: > what is the midpoint of a span? With DateTime::Span: $mid_point = $span->start->add_duration( seconds => $span->duration->seconds / 2 ); With DateTime: $mid_point = $start->add_duration( seconds => $end->subtract_datetime_absolute( $start )->seconds / 2 ); (you may want to account for fractional seconds too) How about a DateTime::Span->midpoint method? - Flavio S. Glock
Re: DateTime::Calendar::Discordian
On Thu, 10 Jun 2004, Dave Rolsky wrote: > Well, Rich Bowen had started working on the same module, so you should > talk to him. Reviewing the code/docs, I have a couple nits: > Oh yeah I just saw that in the list archives. > - The constructor shouldn't take rd_secs, rd_nanosecs, or locale, I don't > think. The only way to set this should be via the from_object method. > Ok. I'll change that. > - I'm assuming that the "holyday" spelling is intentional, right? > Yes. That seems to be the way Discordian texts spell it. > - days_till_x should be days_until_x. I'm not a big fan of abbreviations > in general, unless they're ridiculously obvious, and "till" is the wrong > abbreviation anyway ;) > Ok. I'll change that. > - You have %% documented twice. > > - Using ü in the exclamations probably isn't right. This is part of > Latin-1, so use that character. > I think both of these are artifacts from cutting and pasting from PerlMonks but I'll make sure they are fixed. Apart from being an enjoyable little waste of time, this module is just a warmup for the Hindu calendars I said I was going to do a long time ago. -- Jaldhar H. Vyas <[EMAIL PROTECTED]>
Re: DateTime::Calendar::Discordian
On Thu, 10 Jun 2004, Jaldhar H. Vyas wrote: > While malingering from actual work, I wrote some code to convert dates to > and from the Discordian calendar. Over the past couple of nights I made > it into a proper DateTime::Calendar module which I posted to PerlMonks > (http://www.perlmonks.org/index.pl?node_id=362936) This morning I also > packaged it up into a proper CPAN package which you can find at > http://src.braincells.com/perl/ > > Before I upload it to CPAN, I'd like you to review it and suggest any > improvements, bugfixes etc. Well, Rich Bowen had started working on the same module, so you should talk to him. Reviewing the code/docs, I have a couple nits: - The constructor shouldn't take rd_secs, rd_nanosecs, or locale, I don't think. The only way to set this should be via the from_object method. - I'm assuming that the "holyday" spelling is intentional, right? - days_till_x should be days_until_x. I'm not a big fan of abbreviations in general, unless they're ridiculously obvious, and "till" is the wrong abbreviation anyway ;) - You have %% documented twice. - Using ü in the exclamations probably isn't right. This is part of Latin-1, so use that character. -dave /*=== House Absolute Consulting www.houseabsolute.com ===*/
DateTime::Calendar::Discordian
While malingering from actual work, I wrote some code to convert dates to and from the Discordian calendar. Over the past couple of nights I made it into a proper DateTime::Calendar module which I posted to PerlMonks (http://www.perlmonks.org/index.pl?node_id=362936) This morning I also packaged it up into a proper CPAN package which you can find at http://src.braincells.com/perl/ Before I upload it to CPAN, I'd like you to review it and suggest any improvements, bugfixes etc. -- Jaldhar H. Vyas <[EMAIL PROTECTED]>