I've been exploring the vast and impressive functionality
in the DateTime suite of modules and have
come up with a few questions that are not well answered
in the FAQ so I post them here...

Question #1:
I'm confused by these methods in DateTime::Duration:

        delta_days
        days
        in_units('days')

How are they different?  When would one use each of them?

'delta_days' is apparently just the value you gave
for 'days' when constructing the object.

From its simple name, 'days' _looks_ like it is just
the 'days' value you passed to the constructor but is
actually something quite different.

in_units('days') again seems to just return
the days value you passed to the constructor.
But no... it also adds in 7*weeks.

my $dur = DateTime::Duration->new(
    years => 3,
    weeks => 4,
    months => 1,
    days => 23,
    minutes => 24,
);

print $dur->delta_days(), "\n";
print $dur->days(), "\n";
print $dur->in_units('days'), "\n";

This prints
51
2
51
and so delta_days() is not just the value you passed, either.

I'm confused.   When would one use these methods?
What practical problems would use each of them?

Question #2:
use DateTime::Event::Recurrence;

# Second Tuesday of every month:
#
my $set = DateTime::Event::Recurrence->monthly(
    weeks => 2,
    days => 2
);
my $it = $set->iterator(start => DateTime->now());
for (1 .. 10) {
    my $dt = $it->next();
    print "$dt\n";
}

2010-09-14T00:00:00
2010-10-12T00:00:00
2010-11-09T00:00:00
2010-12-14T00:00:00
2011-01-11T00:00:00
2011-02-15T00:00:00
2011-03-15T00:00:00
2011-04-12T00:00:00
2011-05-10T00:00:00
2011-06-14T00:00:00

This correctly prints the remaining second Tuesdays for 2010
but in 2011 it includes Feb 15th which is the 3rd Tuesday.   
What's up with that?

Reply via email to