Issues

ZF-11735: Zend_Date toString wrongly interprets first argument format as a locale

Description

The code below should print out a date formatted with PHP date formatting rule "MY" where M is a short textual representation of a month, three letters and Y is a full numeric representation of a year, 4 digits.

The problem is that this code example causes an exception: "Missing locale file '/home/robin/hammerkit/hammerkit40/inc/external/Zend/Locale/Data/MY.xml' for 'MY' locale."

It seems that in this case where the string "MY" also is a locale the format argument to the method toString is wrongly interpreted as a locale and not the date formatting rule. The problem seems to be in the file Date.php where the Zend_Date class is defined. On lines 443-445 in this file where the toString method is defined is an if statement with a test "Zend_Locale::isLocale($format, null, false)". Because this returns TRUE for the formatting rule "MY" it then is for some reason interpreted as a locale for the conversions done later in toString, and because of that this results in the exception.

--- Start code example --- Zend_Date::setOptions(array('format_type' => 'php')); $dateObj = new Zend_Date(1315819309, null, 'en_GB'); echo $dateObj->toString('MY'); --- End code example ---

Comments

No comments to display