当前位置: 首页>>代码示例>>PHP>>正文


PHP FormatConverter::convertDateIcuToJui方法代码示例

本文整理汇总了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 \'г\'.'));
 }
开发者ID:howq,项目名称:yii2,代码行数:7,代码来源:FormatConverterTest.php

示例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);
 }
开发者ID:andreosoft,项目名称:andreocms,代码行数:29,代码来源:DatePicker.php

示例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());
 }
开发者ID:sallon88,项目名称:yii2-jui-timepicker,代码行数:35,代码来源:DateTimePicker.php

示例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 [];
     }
 }
开发者ID:maddoger,项目名称:yii2-core,代码行数:15,代码来源:DatePickerConfig.php

示例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()]);
 }
开发者ID:webtoolsnz,项目名称:yii2-widgets,代码行数:17,代码来源:DatePicker.php

示例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);
 }
开发者ID:michael-vostrikov,项目名称:books-test,代码行数:15,代码来源:DatePicker.php

示例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);
 }
开发者ID:omnilight,项目名称:yii2-datetime,代码行数:27,代码来源:DatePickerConfig.php

示例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);
 }
开发者ID:meysampg,项目名称:yii2-jtimepicker,代码行数:21,代码来源:JDateTimePicker.php

示例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());
 }
开发者ID:noname007,项目名称:yii2-1,代码行数:27,代码来源:DatePicker.php

示例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')]]]];
    }
开发者ID:exchangecore,项目名称:yii2-parameters,代码行数:64,代码来源:Type.php

示例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\''));
 }
开发者ID:glcode,项目名称:yii2-2.0.3-annotated,代码行数:5,代码来源:FormatConverterTest.php


注:本文中的yii\helpers\FormatConverter::convertDateIcuToJui方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。