Missing argument 1 for CDateFormatter::__construct()

hi

I put in the config main.php the entry

‘dateFormatter’=>array(‘class’=>‘CDateFormatter’, ‘params’=>array(‘fr’)

    ),

as mentioned in other posts about using CDateFormatter

then in some view

echo Yii::app()->dateFormatter->format(“EEEE”,‘25/02/2010’) ;

I got the message

Missing argument 1 for CDateFormatter::__construct()

In fact the call to CDateFormatter constructors occurs in createComponent() method in YiiBase

the offending call is in line 209 of YiiBase and you figure out that the test there line 190-210 does not make use of params at all so the constructor fails

Anyone had this problem , how to use CDateFormatter from the config main.php ?

thanks

blset

complement :

After removing anything in the config file main.php about a CDateFormatter component,

and inside a view, using Yii::app()->dateFormatter->format("EEE", $date), it works with default language English

someone could explain where does this come from ? where is the configuration for english ?

and why it does not work (see previous post) if a CDateFormatter component is declared in the config file

thanks

CDateFormatter is not an application component. So you can’t declare it in ‘components’ in main.php.

Without declaring it in main.php, you can directly use Yii::app()->dateFormatter because of the existence of CApplication::getDateFormatter().

The date formatter returned uses the locale as specified by Yii::app()->language.

If you want to use the date formatter for a different locale, you can use Yii::app()->getLocale(‘fr’)->dateFormatter