Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.5.0a4

Bug #1240 Integer overflow when constructing Date_Span from two Date objects
Submitted: 2004-04-19 16:31 UTC
From: steve at acidy dot com Assigned: pajoye
Status: Suspended Package: Date
PHP Version: 4.3.4 OS: Windows
Roadmaps: (Not assigned)    

 [2004-04-19 16:31 UTC] steve at acidy dot com
Description: ------------ When constructing a Date_Span object from two Date objects, the Date_Span constructor calculates the number of seconds between the two dates and then passes this between functions. This leads to an integer overflow error when the dates are more than the ~74 years apart. The simplest solution is to change Date_Span so that setFromSeconds isn't called, and the member variables are set in the function directly. Reproduce code: --------------- $d1 = new Date('2005-04-30'); $d2 = new Date('1929-10-13'); print_r(new Date_Span($d1,$d2)) Expected result: ---------------- date_span object ( [day] => something greater than zero! ) Actual result: -------------- date_span Object ( [day] => -22117 [hour] => -7 [minute] => -29 [second] => -16 )


 [2004-04-29 18:10 UTC] paj at pearfr dot org
Have to check how I can fix it without breaking BC. The problem fits in the php integer bounds. A way may be to use float, but BC issues here. Or just do not work in seconds internally, sounds more obvious anyway. I will not have the time to fix it before mid-may, so if anyone has a working patch, feel free to post it here :) --Pierre
 [2004-05-16 12:25 UTC] paj at pearfr dot org
Hello, Cannot be fixed without rewriting most of date_span. The idea to store "huge" timespan using seconds was not good. I doubt that will get fixed in the 1.x branch. -- Pierre
 [2004-05-20 09:30 UTC] pierre at dotgeek dot org
Suspend it for now. No easy way to solve this issue. Should be documented... --Pierre