CDateTimeParser::parse bug

While testing extension DateTimeI18NBehavior I discovered that there might be a bug in CDateTimeParser::parse.

I tried this with locale ‘nl_nl’ and medium date format ‘d MMM yyyy’.


<?php echo '<p>Locale id = '.Yii::app()->locale->id.'</p>';?>

<?php echo '<p>Dateformat = '.Yii::app()->locale->dateFormat.'</p>';?>

<?php $parsedDate = CDateTimeParser::parse('1 okt 2009', Yii::app()->locale->dateFormat);

if (!$parsedDate) echo '<p>Oops .. parsing failed</p>';

else echo '<p>Parsing succeeded'.$parsedDate.'</p>';?>

<?php $parsedDate = CDateTimeParser::parse('01-10-2009', 'dd-mm-yyyy');

if (!$parsedDate) echo '<p>Oops .. parsing failed</p>';

else echo '<p>Parsing succeeded'.$parsedDate.'</p>';?>

Outcome:

Not sure why the first example is not working.

CDateTimeParser only supports month formats ‘M’ and ‘MM’.

/Tommy

You’re right. A little reading could have spared me this ‘problem’. Thanks.