Dan Sully schreef:
> To get the beginning and ending times of a month:
> 
>         2002-12-01 00:00:00
>         2002-12-31 23:59:59
> 
> How would one do this with >= 0.13 releases?

TIMTOWTDI:

    my $dt2 = DateTime->new( month => $month, year => 2002)
                      ->add( months => 1 )
                      ->truncate( to => 'month' )
                      ->subtract( seconds => 1 );

    my $dt3 = DateTime->last_day_of_month( month => $month, year => 2002)
                      ->add( days => 1, seconds => -1 );

But note that the month of December does not end at 2002-12-31T23:59:59!
It doesn't even end at 2002-12-31T23:59:59.999999999, the last moment in
2002 that DateTime can represent. The ending time of 2002-12 is
2003-01-01T00:00:00.

Eugene

Reply via email to