I've uploaded DateTime-Set-0.32 to cpan.
The idea was that you would specify 'end' and a negative duration, like:
DateTime::Span->from_datetime_**and_duration(
end => DateTime->now(),
hours => -24
)
but that would not work because of a bug in 0.31 or before.
The new version ignores the signal of the duration, and it does the right
thing depending on which other endpoint is specified.
diff:
https://github.com/fglock/DateTime-Set/commit/83350c3e99455b5cbd0d2c158b0b7168b5c9908e
Flávio S. Glock
2013/8/27 David Pottage <[email protected]>
>
> Hello
>
> I am attempting to create a number of DateTime::Span objects for the past
hour, past 24 hours, past week etc. The code I am using looks like this:
>
> my $last24hours = DateTime::Span->from_datetime_and_duration(
> end => DateTime->now(),
> duration => DateTime::Duration->new( hours => 24 ),
> );
>
> The code is not working as expected. Instead, I am getting a 24 hour time
span from now into the future rather than into the past.
>
> I have had a peek at the source code for from_datetime_and_duration(),
and it looks like it always adds the duration to the supplied DateTime
regardless of weather it is supplied as a start or end.
>
> Is this a bug? I can supply a test case or patch if necessary.
>
> --
> David Pottage
> CV Library Ltd.
>