Subject: | Unintended side-effect of end day comparison |
Date: | Fri, 30 Nov 2012 08:54:48 +1100 |
To: | bug-DateTime-BusinessHours [...] rt.cpan.org |
From: | Steven Lynch <steven.lynch [...] network-box.com.au> |
Hi,
There appears to be a bug in DateTime::BusinessHours version 2.01 where the end date is truncated as a side-effect of a conditional test.
In the part of the code that tests for the start and end being on different days (line 92).
The line is currently:
# if start and end aren't on the same day
if( $d1->truncate( to => 'day' ) != $d2->truncate( to => 'day' ) ) {
which will truncate $d2 and, unlike $d1, $d2 is used subsequently.
I have tested after avoiding the side-effect, as shown:
if( $d1->truncate( to => 'day' ) != $d2->clone->truncate( to => 'day' ) ) {
and everything seems to work fine.
Regards
Steven
--
Steven Lynch [Chief Engineer]
mailto: steven.lynch@network-box.com.au
Network Box Australia Pty Ltd Phone: +61-3-88410000
14 Ellingworth Parade, Fax: +61-3-88410088
Box Hill, Vic, Australia, 3128 Web: www.network-box.com.au