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

Request #13219 Methods like getNextDay() should check for complete data fields first
Submitted: 2008-02-26 19:59 UTC
From: estigy Assigned:
Status: Open Package: Date (version 1.4.7)
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    
Subscription  


 [2008-02-26 19:59 UTC] estigy (Günther Stadler)
Description: ------------ There are many methods like getNextDay(), dayOfWeek() or daysInMonth() that should raise an error when the needed data fields (year, month, day,..) are not set to a meaningful value. If the Date object is initialized with "2008-00-00", what is dayOfWeek() supposed to return? At some point (directly at the initialization, or when calling of the calculation methods) there should be a warning that the return result simply has to be plain wrong, because there is not enough data to calculate it. Test script: --------------- $foo = new Date('2007-00-00'); var_dump($foo->getDayOfWeek()); Expected result: ---------------- * (bool) false * PEAR_Error * Exception * ... Actual result: -------------- float(4)

Comments

 [2008-05-10 11:51 UTC] firman (Firman Wandayandi)
I think this will break the BC, but it's OK we can start it for 1.5 branch. And well many changes should be done to accomplish this feature.
 [2008-05-12 11:46 UTC] estigy (Günther Stadler)
You are right, this will break bechward compatibility indeed. But I believe that it would make the Date package much more reliable and would reduce the code needed when using the package. Thanks!