Issues

ZF-11289: add large date parts to zend_date object returns false in mktime function

Description

As I quite understand "Add" date method of zend_date object uses "mktime" method to convert date parts into timestamp and then uses them in date calculations. For date object with year between 1901 and 1938 this internal "mktime" limits the size of any parts to be added to maximum unix timestamp = 2147483647 after part conversion. And in this case the feature with bcmath php extension implemented into date object becomes useless. For example, if to add 24856 days to date before 2038 will return false in "mktime" when this large part being converted into timestamp because 24856 days = 2147558400 > 2147483647 = 24855 days (max timestamp). With adding months the situation is even worse as internal "mktime" uses "year" part of date object to convert "month" part as opposed to "day" part which is converted as timestamp from 1970. The problem lies within internal "mktime" method of zend_date object (module: Zend/Date/DateObject.php) in the following line of code with "year" part checking: protected function mktime($hour, $minute, $second, $month, $day, $year, $gmt = false) { // complete date but in 32bit timestamp - use PHP internal if ((1901 < $year) and ($year < 2038)) {...

What I would suggest is to make the following minor changes into this internal "mktime" function: protected function mktime($hour, $minute, $second, $month, $day, $year, $gmt = false) { $year_x = $year + $day/365+$month/12+$hour/(36524)+$minute/(3652460)+$second/(365246060); // complete date but in 32bit timestamp - use PHP internal if ((1901 < $year_x) and ($year_x < 2038)) {... After this changes internal "mktime" will check the resulting year instead of "year" part and use bcmath if any part is larger then maximum timestamp after conversion Thank you

Comments

No comments to display