Yii2: Date discreapncies between Formatter::asDate() and FormatConverter::convertDateIcuToJui() discrepancies

Created on 4 Aug 2015  路  8Comments  路  Source: yiisoft/yii2

I noticed the following differences when using jQuery-UI Datepicker. Formatter was providing the date input's initial value on page load and the format changed after using Datepicker.

Both are ICU 'medium'.

| locale | asDate() | convertDateIcuToJui() |
| --- | --- | --- |
| en-US | Apr 4, 2015 | Apr 4 2015 |
| ru-RU | 04 邪胁谐. 2015 谐. | 04 袗胁谐 2015 谐. |

or something like that

jui

All 8 comments

I am unable to reproduce this, do you have the PHP intl extension installed?

The discrepancy has changed since I last tested it.

intl 1.1.0
ICU 52.1
PHP 7.0.11

In app config

    'language' => 'ru-RU',

Model and controller

<?php

class TestForm extends \yii\base\Model
{
    public $date = '2016-11-27';
}

class TestController extends \yii\web\Controller
{
    public function actionTest()
    {
        return $this->render('test', ['model' => new TestForm()]);
    }
}

View

<?php $form = \yii\widgets\ActiveForm::begin(); ?>
<?= $form->field($model, 'date')->widget(\yii\jui\DatePicker::className(), ['dateFormat' => 'medium']) ?>
<?php \yii\widgets\ActiveForm::end(); ?>

Initial page load

Alt text

Click on 27 Nov in the date picker

Alt text

Date is now formatted as

Alt text

i cannot be sure that intl was installed when i ran the test in aug last year but it most likely was because i have required it as standard for years

confirm now

bower-asset/bootstrap                   v3.3.7            
bower-asset/highcharts                  v5.0.14           
bower-asset/inputmask                   3.3.10            
bower-asset/jquery                      3.2.1             
bower-asset/jquery-ui                   1.11.4            
bower-asset/punycode                    v1.3.2            
bower-asset/typeahead.js                v0.11.1           
bower-asset/yii2-pjax                   2.0.7.1           
yiisoft/yii2                            dev-master 1ad69de Yii PHP Framework Version 2
yiisoft/yii2-jui                        dev-master 75e6f78 The Jquery UI extension for the Yii framework

php: 7.1.10-fpm-alpine-4yii2-xdebug

intl 1.1.0 

ICU version => 57.1
ICU Data version => 57.1

```
requirements.php
ICU version: OK
ICU Data version: OK

```php
<?php
\Yii::$app->language = 'ru';
class TestForm extends \yii\base\Model
{
    public $date = '2017-10-25';
}
$model = new TestForm;
$form = \yii\widgets\ActiveForm::begin();
?>
<?= $form->field($model, 'date')->widget(\yii\jui\DatePicker::className(), ['dateFormat' => 'medium']) ?>
<?php \yii\widgets\ActiveForm::end(); ?>

peek 2017-10-25 12-19

@bscheshirwork thanks for the detailed research. I just looked into the jquery UI sources and found that they have hardcoded the month names:

https://github.com/jquery/jquery-ui/blob/74f8a0ac952f6f45f773312292baef1c26d81300/ui/i18n/datepicker-ru.js#L22-L23

@cebe
So... This issue can be moved to yiisoft/yii2-jui and can be remove from milestone 2.0.13?

So... This issue can be moved to yiisoft/yii2-jui and can be remove from milestone 2.0.13?

yep, thanks for noting.

Was this page helpful?
0 / 5 - 0 ratings