yiisoft/yii — pull request #3230 by Deconstrained (2014-02-15 01:03:11+00:00)
Title: Added consistency between date/time format/parse

The way CDateFormatter formats dates and interprets formats is inconsistent
with CDateTimeParser, in that "y" will be transformed to "2014" by
CDateFormatter's formatting functions, whereas to read all four digits,
the year part of the format string passed to CDateTimeParser.parse must
contain all four digits. Thus, in the following code, the resulting
value of $date would be false rather than the original timestamp:

$date = 1392424866;
$dateTimeFormat = Yii::app()->locale->getDateFormat('medium').' '.Yii::app()->locale->getTimeFormat('medium');
$date = Yii::app()->dateFormatter->format($dateTimeFormat,$date);
$date = CDateTimeParser::parse($date,$dateTimeFormat);

This change makes CDateTimeParser behave more like the inverse map of
CDateTimeFormatter's formatting functions, and $date in the above code
would evaluate to 1392424866 at the end.