Skip to content

Commit b47100e

Browse files
committed
use widget language for converting ICU format
1 parent a5ca3f2 commit b47100e

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

DateTimePicker.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,20 @@ class DateTimePicker extends \yii\widgets\InputWidget
7777
*/
7878
public $type = self::TYPE_DATETIME;
7979

80+
/**
81+
* @inheritdoc
82+
*/
83+
public function init()
84+
{
85+
parent::init();
86+
if ($this->language === null) {
87+
$this->language = Yii::$app->language;
88+
}
89+
}
90+
91+
/**
92+
* @inheritdoc
93+
*/
8094
public function run()
8195
{
8296
Html::addCssClass($this->options, 'form-control');
@@ -146,9 +160,6 @@ protected function registerLanguage($view)
146160
return;
147161
}
148162
$language = $this->language;
149-
if ($language === null) {
150-
$language = Yii::$app->language;
151-
}
152163

153164
$language = str_replace('_', '-', strtolower($language));
154165

@@ -189,7 +200,7 @@ protected function registerFormat()
189200
} elseif (strncmp($format, 'moment:', 7) === 0) {
190201
$format = substr($format, 7);
191202
} else {
192-
$format = FormatConverter::convertDateIcuToMoment($format, $this->type);
203+
$format = FormatConverter::convertDateIcuToMoment($format, $this->type, $this->language);
193204
}
194205
$this->clientOptions['format'] = $format;
195206
}

0 commit comments

Comments
 (0)