Ron Hill said:
>
> I would like to be able to change
> the max and min values that are in a DateTime Set
> object. Here is a test script that demonstrates
> my problem.
>
[...]
>
> #generate a monthly set object that has min set to
the first day of the month
> # max set to last day of the month
>
> my $dt_set = DateTime::Set->from_datetimes(
> dates => [
> DateTime->today->truncate( to => 'month'
)->subtract( months => 1 ),
> DateTime->last_day_of_month(
> year => DateTime->today->year,
> month => DateTime->today->subtract(
months => 1 )->month
> )
> ]
> );
> # ok goo so far now I need to add 23 hours and 50
min to the
> # max value
>
> my $dt = DateTime::Duration->new( hours=>23,
minutes =>50);
>
> $dt_set->max->add($dt);
max() is a "getter" method. It returns a DateTime.
You can't use it to set the max value.
Either you create a new set, or you make a "union"
with the new max value.
$dt_set = $dt_set->union(
$dt_set->max->add($dt)
);
OTOH, maybe you need a DateTime::Span instead of
a DateTime::Set:
$dt_span = DateTime::Span->from_datetimes(
start => $dt_set->min,
end => $dt_set->max->add($dt)
);
- Flavio S. Glock