本文整理汇总了PHP中yii\helpers\FormatConverter::convertDateIcuToJui方法的典型用法代码示例。如果您正苦于以下问题:PHP FormatConverter::convertDateIcuToJui方法的具体用法?PHP FormatConverter::convertDateIcuToJui怎么用?PHP FormatConverter::convertDateIcuToJui使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\helpers\FormatConverter
的用法示例。
在下文中一共展示了FormatConverter::convertDateIcuToJui方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIntlUtf8Ru
public function testIntlUtf8Ru()
{
$this->assertEquals('d M Y \\г.', FormatConverter::convertDateIcuToPhp('dd MMM y \'г\'.', 'date', 'ru-RU'));
$this->assertEquals('dd M yy \'г\'.', FormatConverter::convertDateIcuToJui('dd MMM y \'г\'.', 'date', 'ru-RU'));
$formatter = new Formatter(['locale' => 'ru-RU']);
$this->assertEquals('24 авг 2014 г.', $formatter->asDate('2014-8-24', 'dd MMM y \'г\'.'));
}
示例2: run
public function run()
{
echo $this->renderWidget() . "\n";
$view = $this->getView();
$bundle = Asset::register($view);
$containerID = $this->inline ? $this->containerOptions['id'] : $this->options['id'];
$language = $this->language ? $this->language : \Yii::$app->language;
if (strncmp($this->dateFormat, 'php:', 4) === 0) {
$this->clientOptions['format'] = FormatConverter::convertDatePhpToJui(substr($this->dateFormat, 4), 'date', $language);
} else {
$this->clientOptions['format'] = FormatConverter::convertDateIcuToJui($this->dateFormat, 'date', $language);
}
$this->clientOptions['format'] = 'yyyy-mm-dd';
if ($language != 'en-US') {
if ($bundle->autoGenerate) {
$fallbackLanguage = substr($language, 0, 2);
if ($fallbackLanguage !== $language && !file_exists(\Yii::getAlias($bundle->sourcePath . "/locales/bootstrap-datepicker.{$language}.js"))) {
$language = $fallbackLanguage;
}
// $view->registerJsFile($bundle->baseUrl . "/locales/bootstrap-datepicker.$language.js");
}
$options = Json::encode($this->clientOptions);
$view->registerJs("\$('#{$containerID}').datepicker(\$.extend({}, {$options}));");
// $view->registerJs("$('#{$containerID}').datepicker($.extend({}, $.datepicker.regional['{$language}'], $options));");
} else {
$this->registerClientOptions('datepicker', $containerID);
}
// $this->registerClientEvents('datepicker', $containerID);
}
示例3: run
/**
* Renders the widget.
*/
public function run()
{
$picker = $this->timeOnly ? 'timepicker' : 'datetimepicker';
echo $this->renderWidget() . "\n";
$containerID = $this->inline ? $this->containerOptions['id'] : $this->options['id'];
$language = $this->language ? $this->language : Yii::$app->language;
if (strncmp($this->dateFormat, 'php:', 4) === 0) {
$this->clientOptions['dateFormat'] = FormatConverter::convertDatePhpToJui(substr($this->dateFormat, 4), 'date', $language);
} else {
$this->clientOptions['dateFormat'] = FormatConverter::convertDateIcuToJui($this->dateFormat, 'date', $language);
}
if ($this->timeFormat) {
$this->clientOptions['timeFormat'] = $this->timeFormat;
}
if ($language != 'en-US' && $language != 'en') {
$view = $this->getView();
$bundle = DateTimePickerLanguageAsset::register($view);
if ($bundle->autoGenerate) {
$fallbackLanguage = substr($language, 0, 2);
if ($fallbackLanguage !== $language && !file_exists(Yii::getAlias($bundle->sourcePath . "/dist/i18n/jquery-ui-timepicker-{$language}.js"))) {
$language = $fallbackLanguage;
}
$view->registerJsFile($bundle->baseUrl . "/dist/i18n/jquery-ui-timepicker-{$language}.js", ['depends' => [DateTimePickerAsset::className()]]);
}
$options = Json::encode($this->clientOptions);
$view->registerJs("\$('#{$containerID}').{$picker}(\$.extend({}, \$.timepicker.regional['{$language}'], {$options}));");
} else {
$this->registerClientOptions($picker, $containerID);
}
$this->registerClientEvents($picker, $containerID);
DateTimePickerAsset::register($this->getView());
}
示例4: jui
/**
* @param DateTimeAttribute $attribute
* @param string $datePickerClass
* @return array
*/
public static function jui($attribute, $datePickerClass = 'yii\\jui\\DatePicker')
{
$format = $attribute->localFormat;
switch ($datePickerClass) {
case 'yii\\jui\\DatePicker':
return ['language' => \Yii::$app->language, 'clientOptions' => ['dateFormat' => FormatConverter::convertDateIcuToJui($format[1], $format[0])]];
default:
return [];
}
}
示例5: init
/**
* @throws \yii\base\InvalidConfigException
*/
public function init()
{
parent::init();
Html::addCssClass($this->options, ['progressive-datepicker', 'form-control']);
if (!$this->dateFormat) {
$this->dateFormat = Yii::$app->formatter->dateFormat;
}
if (strncmp($this->dateFormat, 'php:', 4) === 0) {
$this->clientOptions['dateFormat'] = FormatConverter::convertDatePhpToJui(substr($this->dateFormat, 4));
} else {
$this->clientOptions['dateFormat'] = FormatConverter::convertDateIcuToJui($this->dateFormat);
}
$this->options = array_merge($this->options, ['type' => 'date', 'value' => $this->getDate(), 'formattedValue' => $this->getFormattedDate()]);
}
示例6: registerScript
public function registerScript()
{
$language = $this->language ? $this->language : Yii::$app->language;
if (strncmp($this->saveDateFormat, 'php:', 4) === 0) {
$saveDateFormatJs = FormatConverter::convertDatePhpToJui(substr($this->saveDateFormat, 4));
} else {
$saveDateFormatJs = FormatConverter::convertDateIcuToJui($this->saveDateFormat, 'date', $language);
}
$this->saveDateFormatJs = $saveDateFormatJs;
$containerID = $this->inline ? $this->containerOptions['id'] : $this->options['id'];
$hiddenInputID = $this->options['savedValueInputID'];
$script = "\r\n \$('#{$containerID}').change(function() {\r\n var savedValue = \$.datepicker.formatDate('{$saveDateFormatJs}', \$(this).datepicker('getDate'));\r\n \$('#{$hiddenInputID}').val(savedValue).trigger('change');\r\n });\r\n ";
$view = $this->getView();
$view->registerJs($script);
}
示例7: get
/**
* @param Model $model
* @param $attribute
* @param array $options
* @param string $datePickerClass
* @return array
*/
public static function get(Model $model, $attribute, $options = [], $datePickerClass = 'yii\\jui\\DatePicker')
{
try {
$attribute = self::findAttribute($model, $attribute);
$format = DateTimeBehavior::normalizeIcuFormat($attribute->targetFormat, $attribute->behavior->formatter);
switch ($datePickerClass) {
case 'yii\\jui\\DatePicker':
$defaults = ['language' => \Yii::$app->language, 'clientOptions' => ['dateFormat' => 'php:' . FormatConverter::convertDateIcuToJui($format[1], $format[0])]];
break;
case 'omnilight\\widgets\\DatePicker':
$defaults = ['language' => \Yii::$app->language, 'dateFormat' => 'php:' . FormatConverter::convertDateIcuToPhp($format[1], $format[0])];
break;
default:
return $options;
}
} catch (InvalidParamException $e) {
$defaults = [];
}
return ArrayHelper::merge($defaults, $options);
}
示例8: run
public function run()
{
$view = $this->getView();
echo $this->renderWidget() . "\n";
$containerID = $this->inline ? $this->containerOptions['id'] : $this->options['id'];
$language = $this->language ? $this->language : Yii::$app->language;
if (strncmp($this->dateFormat, 'php:', 4) === 0) {
$this->clientOptions['dateFormat'] = FormatConverter::convertDatePhpToJui(substr($this->dateFormat, 4));
} else {
$this->clientOptions['dateFormat'] = FormatConverter::convertDateIcuToJui($this->dateFormat, 'date', $language);
}
if ($language !== 'en-US') {
$options = Json::htmlEncode($this->clientOptions);
$language = Html::encode($language);
$view->registerJs("\$('#{$containerID}').datetimepicker(\$.extend({}, \$.datepicker.regional['{$language}'], {$options}));");
} else {
$this->registerClientOptions('datetimepicker', $containerID);
}
$this->registerClientEvents('datetimepicker', $containerID);
JTimePickerAsset::register($view);
}
示例9: run
/**
* Renders the widget.
*/
public function run()
{
echo $this->renderWidget() . "\n";
$containerID = $this->inline ? $this->containerOptions['id'] : $this->options['id'];
$language = $this->language ? $this->language : Yii::$app->language;
if (strncmp($this->dateFormat, 'php:', 4) === 0) {
$this->clientOptions['dateFormat'] = FormatConverter::convertDatePhpToJui(substr($this->dateFormat, 4), 'date', $language);
} else {
$this->clientOptions['dateFormat'] = FormatConverter::convertDateIcuToJui($this->dateFormat, 'date', $language);
}
if ($language != 'en-US') {
$view = $this->getView();
$bundle = DatePickerLanguageAsset::register($view);
if ($bundle->autoGenerate) {
$view->registerJsFile($bundle->baseUrl . "/ui/i18n/datepicker-{$language}.js", ['depends' => [JuiAsset::className()]]);
}
$options = Json::encode($this->clientOptions);
$view->registerJs("\$('#{$containerID}').datepicker(\$.extend({}, \$.datepicker.regional['{$language}'], {$options}));");
} else {
$this->registerClientOptions('datepicker', $containerID);
}
$this->registerClientEvents('datepicker', $containerID);
JuiAsset::register($this->getView());
}
示例10: getTypeList
public static function getTypeList()
{
$dateFormat = Yii::$app->formatter->dateFormat;
if (strncmp(Yii::$app->formatter->dateFormat, 'php:', 4) === 0) {
$dateFormat = FormatConverter::convertDatePhpToJui(substr($dateFormat, 4));
} else {
$dateFormat = FormatConverter::convertDateIcuToJui($dateFormat, 'date', Yii::$app->language);
}
return [static::TEXT_TYPE => ['comparisons' => static::getTextTypeComparisons(), 'formatter' => 'raw', 'options' => ['inputType' => 'text']], static::NUMERIC_TYPE => ['comparisons' => static::getNumericTypeComparisons(), 'formatter' => 'integer', 'options' => ['inputType' => 'text']], static::DATE_TYPE => ['comparisons' => static::getDateTypeComparisons(), 'formatter' => ['date', 'php:Y-m-d'], 'options' => ['inputType' => 'date', 'language' => Yii::$app->language, 'renderScript' => new JsExpression('function(parameter) {
var self = this;
parameter.row.find(".datepicker").each(function(){
var datePicker = $(this);
var parameterValue = datePicker.prev(".parameter-value");
function parseISO8601(dateStringInRange) {
var isoExp = /^\\s*(\\d{4})-(\\d\\d)-(\\d\\d)\\s*$/,
date = new Date(NaN), month,
parts = isoExp.exec(dateStringInRange);
if(parts) {
month = +parts[2];
date.setFullYear(parts[1], month - 1, parts[3]);
if(month != date.getMonth() + 1) {
date.setTime(NaN);
}
}
return date;
}
var dt = parseISO8601(datePicker.val());
dt.setTime( dt.getTime() + dt.getTimezoneOffset()*60*1000 );
var options = $.extend(
{
"defaultValue": dt,
"altField": parameterValue,
"onClose": function(dateText, inst) {
if (dateText == "") {
var altField = $(inst.settings["altField"]);
if (altField.length) {
altField.val(dateText);
}
}
parameterValue.trigger("change");
}
},
self.clientOptions
);
if (self.language !== "en-US") {
options = $.extend(options, $.datepicker.regional[self.language]);
}
datePicker.datepicker(options).datepicker("setDate", dt);
});
}'), 'postRenderScript' => new JsExpression('function(parameter) {
parameter.row.find(".datepicker").each(function(){
var datePicker = $(this);
var parameterValue = datePicker.prev(".parameter-value");
parameterValue.trigger("change");
});
}'), 'clientOptions' => ['dateFormat' => $dateFormat, 'altFormat' => 'yy-mm-dd']]], static::LIST_TYPE => ['comparisons' => static::getListTypeComparisons(), 'formatter' => 'raw', 'options' => ['inputType' => 'select', 'renderScript' => new JsExpression('function(parameter) {
parameter.row.find(".parameter-value").select2({ "width": "100%" });
}'), 'valueOptions' => ['' => '']]], static::BOOL_TYPE => ['comparisons' => static::getBooleanTypeComparison(), 'formatter' => 'integer', 'options' => ['inputType' => 'select', 'valueOptions' => ['' => '', '0' => Yii::t('modules/parameters', 'False'), '1' => Yii::t('modules/parameters', 'True')]]]];
}
示例11: testEscapedIcuToJui
public function testEscapedIcuToJui()
{
$this->assertEquals('l, F j, Y \\a\\t g:i:s a T', FormatConverter::convertDateIcuToPhp('EEEE, MMMM d, y \'at\' h:mm:ss a zzzz'));
$this->assertEquals('\'o\'\'clock\'', FormatConverter::convertDateIcuToJui('\'o\'\'clock\''));
}