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

Doc Bug #15029 large Date_Span's cannot be created
Submitted: 2008-11-14 15:59 UTC
From: merijnvdk Assigned: cweiske
Status: Closed Package: Date (version 1.4.7)
PHP Version: 5.2.6 OS: linux
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 36 - 20 = ?

 
 [2008-11-14 15:59 UTC] merijnvdk (Merijn Van Den Kroonenberg)
Description: ------------ When creating a Date_Span with alot of days (say 40000), the span is invalid. Internally the toSeconds() and setFromSeconds() methods are used for most other setters/construction methods. With alot of days this seems to result in too many seconds (maxint?). Can be worked around by assigning the Date_Span properties manually.

Comments

 [2008-11-17 00:34 UTC] doconnor (Daniel O'Connor)
Hi Merjin, I dont suppose you can attach a small executable test case? The constructor for a Date_Span has a lot of different execution paths, and it would help to know where to start looking. Are you doing: $ds = new Date_Span(new Date('1970-01-01'), new Date()); or something different?
 [2008-11-17 08:45 UTC] merijnvdk (Merijn Van Den Kroonenberg)
It doesn't matter which constructor method is used, it looks like all of them use toSeconds() somewhere in its execution path. Samples: // this one will be allright $ds = new Date_Span(new Date('1941-01-01'), new Date()); echo $ds->toDays()."\n"; echo $ds->toSeconds()."\n"; // results in: // 24792.447696759 // 2142067481 // this one will be bad $ds = new Date_Span(new Date('1940-01-01'), new Date()); echo $ds->toDays()."\n"; echo $ds->toSeconds()."\n"; // results in: // -24552.909074074 // -2121371344 The toDays() method should be safe, because it doesn't use a conversion to seconds. The problem does seem to be because of int overflow in the constructor execution path.
 [2009-01-15 15:04 UTC] doconnor (Daniel O'Connor)
Probably verges on a wontfix => wont it be lovely when we have 64 bit computers everywhere.
 [2009-01-15 15:26 UTC] merijnvdk (Merijn Van Den Kroonenberg)
Yeah I guess its a far from trivial fix. If it is not fixed it should become a documentation issue ;) (beware of date spans larger than 67 years..)
 [2009-08-25 12:02 UTC] cweiske (Christian Weiske)
-Status: Feedback +Status: Open -Type: Bug +Type: Documentation Problem
 [2009-10-15 03:06 UTC] cweiske (Christian Weiske)
-Status: Open +Status: Closed -Assigned To: +Assigned To: cweiske
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.
 [2009-11-01 20:52 UTC] nakayama (kazuhiko nakayama)
Date 1.5.0a. Date_Span , toDay() method is strange. he return 0 only. Where can I get latest "Date" library , What is "SVN" ? How to download it ?? please advice me. ---- require_once("Date.php"); $startDate = new Date( "2008-02-12" ); $endDate = new Date( "2008-03-01" ); print "Days: " . $startDate->format( "%Y-%m-%d" ) . " to " . $endDate->format( "%Y-%m-%d" ) . "\n<br>"; $diff = new Date_Span(); $diff->setFromDateDiff( $startDate, $endDate ); $exDay = $diff->toDays(); print $exDay ." days\n<br>";