NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

## All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.

Full
Abbreviated
Hidden
• #### There's always the DateTime FAQ code...(Score:1)

by Hasher_Bob (8066) on 2007.08.07 17:07 (#56826)
http://datetime.perl.org/index.cgi?FAQSampleCalculations [perl.org]

# As a Perl list
my \$start_dt = DateTime->new(year => 1998, month  => 4,  day => 7);
my \$end_dt   = DateTime->new(year => 1998, month  => 7,  day => 7);

my @list = ();
for (my \$dt = \$start_dt->clone();
\$dt <= \$end_dt;
\$dt->add(weeks => 1) )
{
push @list, \$dt->clone();
}

# As a DateTime::Set.  We use DateTime::Event::Recurrence to easily
# create the sets (see also DateTime::Event::ICal for more
# complicated sets)
use DateTime::Event::Recurrence;
use DateTime::Span;
my \$set = DateTime::Event::Recurrence->daily(start    => \$start_dt,
interval => 7);

\$set = \$set->intersection(DateTime::Span->from_datetimes(start => \$start_dt, end => \$end_dt ));
• #### Re:(Score:2)

The first of those solutions only works if you know the size of the intervals you want to partition into ahead of time. I want to deal with the general case: say I have two moments in time that are exactly 29 days, 3 hours, 1 minute, and 17 seconds apart, and I want to divide it into 8 equal intervals? (My next journal entry does reveal the solution, but I'm just responding to show that I'm dealing with a harder problem than your solution addressed.)

I think the same is true of the second solution. The

--
J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers