Issue Type: Bug Created: 2009-09-11T11:15:24.000+0000 Last Updated: 2009-09-15T08:11:25.000+0000 Status: Resolved Fix version(s): - 1.10.0 (27/Jan/10)
Reporter: thomas (thomas963) Assignee: Thomas Weidner (thomas) Tags: - Zend_Date
Related issues: Attachments:
Zend_Date::setOptions(array('format_type' => 'php')) is no more taken into account for date process.
Following the next exemple, the get method of Zend_Date send back result from ISO format when it should be PHP format as it is asking by the options settings:
Zend_Date::setOptions(array('format_type' => 'php')); Zend_Locale_Format::setOptions(array('locale' => 'en_US', 'fix_date' => true, 'format_type' => 'php')); $today = Zend_Date::now(); $today->setOptions(array('format_type' => 'php')); echo $today->get('m'); // Should send back the month with two digits (PHP format), but send back the minutes (ISO format) echo $today->get('MM'); // Should send back the month with 3 letters and this three times (PHP format), but send back the month with two digits (ISO format)
Seems a major bug as all project based on PHP date format using Zend_Date should break. This problem is not in ZF 1.7.8, but appears in 1.8.0 and is always in 1.9.2.
Actually, I work on a big project, but I cannot upgrade Zend Framework because of this problem.
I hope it will be corrected in next release. Someone get a patch to make it work ?
Best regards, Thomas.
Posted by Thomas Weidner (thomas) on 2009-09-12T05:21:26.000+0000
Can not reproduce....
*) toString accepts php and iso format as expected *) get accepts only iso format as expected
Additionally the given example is not correct... gnu defines that "MM" returns 6 letters (2x3) and not 3 letters 3 times...
Posted by Thomas Weidner (thomas) on 2009-09-13T04:37:02.000+0000
Feature added in trunk.
Posted by thomas (thomas963) on 2009-09-14T03:38:59.000+0000
Thanks a lot, it work great now ! I can go from 1.7.8 to 1.9.2 with the Date.php of the trunk version.
Just a question, what is the difference between toString() and get() method as both send part date in string format (or int) depending locale. In the manuel, it is not saying that PHP Format is not supported by the 'format' type options, should be more explicit maybe. And in Zend 1.7.8, get() method take into account 'php' for format type. But from the next minor release, all will be ok for everyone.
Thanks again. Cheers, Thomas.
p.s: yes, i write my message too fast, your are right, it is 6 letters (2x3)
Posted by Thomas Weidner (thomas) on 2009-09-14T10:49:26.000+0000
As you can see by the methods API, toString accepts a type parameter which can be used to define the used format type. The get method does not have this parameter.
This means, that toString was intended to accept different types of inputs, whereas get is a method to get the actual representation by iso only.
Also the default formats for both methods differ for this reason. They have been intended for different purposes even if this is now no longer the case as people have requested features from one to be integrated in the other and reverse.
Posted by thomas (thomas963) on 2009-09-15T08:11:21.000+0000
But in 1.7.8 and earlier version, the get method take into account the option format_type. So 1.78 and earlier was wrong. It is a strong change wich should be mentionned in documentation for migration. As all people working with zend_date in php format in 1.7.8 will have to migrate code for 1.8+ versions.
New problem: I find a new bug, wich appear only with the Date.php available in the trunk directory (version Id: Date.php 18093 2009-09-13 11:35:01Z thomas) with the patch you have done for my previous problem. With the original 1.9.2 Date.php, this bug in not here, so I guess it comes from your modifications.
IsLater and IsEarlier method for zend_date object send strange return value. Exemple:
Zend_Loader::loadClass('Zend_Date'); Zend_Date::setOptions(array('format_type' => 'php')); // This bug appears only when php format is actived, with the trunck Date.php version Id: Date.php 18093 2009-09-13 11:35:01Z thomas $date1 = new Zend_Date(); $date2 = clone $date1; $date2->add(1, Zend_Date::DAY);
echo "Is date1 earlier than date2:".$date1->isEarlier($date2, Zend_Date::DATES)."
"; // return false echo "Is date2 earlier than date1:".$date2->isEarlier($date1, Zend_Date::DATES)."
"; // return false echo "Is date1 later than date2:".$date1->isLater($date2, Zend_Date::DATES)."
"; // return true echo "Is date2 later than que date1:".$date2->isLater($date1, Zend_Date::DATES)."
"; // return true
Results are not possible. So maybe you need to check better the correction made previously as it impacts "isEarlier" and "isLater" method which rely on "compare" / "_calculate" methods.
Thanks again. Cheers, Thomas.
Have you found an issue?
See the Overview section for more details.