diff --git a/modules/backend/assets/js/october-min.js b/modules/backend/assets/js/october-min.js index 3d8b366c4..6bd3461f6 100644 --- a/modules/backend/assets/js/october-min.js +++ b/modules/backend/assets/js/october-min.js @@ -1167,6 +1167,8 @@ if(this.options.formatAlias){this.options.format=this.getFormatFromAlias(this.op this.appTimezone=$('meta[name="app-timezone"]').attr('content') if(!this.appTimezone){this.appTimezone='UTC'}} DateTimeConverter.prototype.getDateTimeValue=function(){this.datetime=this.$el.attr('datetime') +if(this.$el.get(0).hasAttribute('data-ignore-timezone')){this.appTimezone='UTC' +this.options.timezone='UTC'} var momentObj=moment.tz(this.datetime,this.appTimezone),result if(this.options.locale){momentObj=momentObj.locale(this.options.locale)} if(this.options.timezone){momentObj=momentObj.tz(this.options.timezone)} diff --git a/modules/backend/assets/js/october.datetime.js b/modules/backend/assets/js/october.datetime.js index 4a93201e3..ae4299669 100644 --- a/modules/backend/assets/js/october.datetime.js +++ b/modules/backend/assets/js/october.datetime.js @@ -43,7 +43,6 @@ DateTimeConverter.prototype.constructor = DateTimeConverter DateTimeConverter.prototype.init = function() { - this.initDefaults() this.$el.text(this.getDateTimeValue()) @@ -77,6 +76,11 @@ DateTimeConverter.prototype.getDateTimeValue = function() { this.datetime = this.$el.attr('datetime') + if (this.$el.get(0).hasAttribute('data-ignore-timezone')) { + this.appTimezone = 'UTC' + this.options.timezone = 'UTC' + } + var momentObj = moment.tz(this.datetime, this.appTimezone), result diff --git a/modules/backend/formwidgets/DatePicker.php b/modules/backend/formwidgets/DatePicker.php index b10789b22..c705f8fb4 100644 --- a/modules/backend/formwidgets/DatePicker.php +++ b/modules/backend/formwidgets/DatePicker.php @@ -52,6 +52,11 @@ class DatePicker extends FormWidgetBase */ public $firstDay = 0; + /** + * @var bool change datetime exactly as is in database + */ + public $ignoreTimezone = false; + // // Object properties // @@ -73,6 +78,7 @@ class DatePicker extends FormWidgetBase 'maxDate', 'yearRange', 'firstDay', + 'ignoreTimezone', ]); $this->mode = strtolower($this->mode); @@ -120,6 +126,7 @@ class DatePicker extends FormWidgetBase $this->vars['maxDate'] = $this->maxDate; $this->vars['yearRange'] = $this->yearRange; $this->vars['firstDay'] = $this->firstDay; + $this->vars['ignoreTimezone'] = $this->ignoreTimezone; $this->vars['format'] = $this->format; $this->vars['formatMoment'] = $this->getDateFormatMoment(); $this->vars['formatAlias'] = $this->getDateFormatAlias(); diff --git a/modules/backend/formwidgets/datepicker/partials/_datepicker.htm b/modules/backend/formwidgets/datepicker/partials/_datepicker.htm index 090c9a0b5..d131814a2 100644 --- a/modules/backend/formwidgets/datepicker/partials/_datepicker.htm +++ b/modules/backend/formwidgets/datepicker/partials/_datepicker.htm @@ -15,6 +15,7 @@ data-max-date="" data-year-range="" data-first-day="" + data-ignore-timezone > diff --git a/modules/backend/helpers/Backend.php b/modules/backend/helpers/Backend.php index ee4b9f779..cbc084999 100644 --- a/modules/backend/helpers/Backend.php +++ b/modules/backend/helpers/Backend.php @@ -116,6 +116,7 @@ class Backend 'jsFormat' => null, 'timeTense' => false, 'timeSince' => false, + 'ignoreTimezone' => false, ], $options)); $carbon = DateTimeHelper::makeCarbon($dateTime); @@ -132,6 +133,10 @@ class Backend 'data-datetime-control' => 1, ]; + if ($ignoreTimezone) { + $attributes['data-ignore-timezone'] = true; + } + if ($timeTense) { $attributes['data-time-tense'] = 1; } diff --git a/modules/backend/widgets/Lists.php b/modules/backend/widgets/Lists.php index 2ce367e6a..614cb19ef 100644 --- a/modules/backend/widgets/Lists.php +++ b/modules/backend/widgets/Lists.php @@ -1006,11 +1006,17 @@ class Lists extends WidgetBase $value = $dateTime->toDayDateTimeString(); } - return Backend::dateTime($dateTime, [ + $options = [ 'defaultValue' => $value, 'format' => $column->format, 'formatAlias' => 'dateTimeLongMin' - ]); + ]; + + if (!empty($column->config['ignoreTimezone'])) { + $options['ignoreTimezone'] = true; + } + + return Backend::dateTime($dateTime, $options); } /** @@ -1028,11 +1034,17 @@ class Lists extends WidgetBase $value = $dateTime->format($format); - return Backend::dateTime($dateTime, [ + $options = [ 'defaultValue' => $value, 'format' => $column->format, 'formatAlias' => 'time' - ]); + ]; + + if (!empty($column->config['ignoreTimezone'])) { + $options['ignoreTimezone'] = true; + } + + return Backend::dateTime($dateTime, $options); } /** @@ -1053,11 +1065,17 @@ class Lists extends WidgetBase $value = $dateTime->toFormattedDateString(); } - return Backend::dateTime($dateTime, [ + $options = [ 'defaultValue' => $value, 'format' => $column->format, 'formatAlias' => 'dateLongMin' - ]); + ]; + + if (!empty($column->config['ignoreTimezone'])) { + $options['ignoreTimezone'] = true; + } + + return Backend::dateTime($dateTime, $options); } /** @@ -1073,10 +1091,16 @@ class Lists extends WidgetBase $value = DateTimeHelper::timeSince($dateTime); - return Backend::dateTime($dateTime, [ + $options = [ 'defaultValue' => $value, 'timeSince' => true - ]); + ]; + + if (!empty($column->config['ignoreTimezone'])) { + $options['ignoreTimezone'] = true; + } + + return Backend::dateTime($dateTime, $options); } /** @@ -1092,10 +1116,16 @@ class Lists extends WidgetBase $value = DateTimeHelper::timeTense($dateTime); - return Backend::dateTime($dateTime, [ + $options = [ 'defaultValue' => $value, 'timeTense' => true - ]); + ]; + + if (!empty($column->config['ignoreTimezone'])) { + $options['ignoreTimezone'] = true; + } + + return Backend::dateTime($dateTime, $options); } /** diff --git a/modules/system/assets/ui/js/datepicker.js b/modules/system/assets/ui/js/datepicker.js index b83e6fd09..a1d84cd10 100644 --- a/modules/system/assets/ui/js/datepicker.js +++ b/modules/system/assets/ui/js/datepicker.js @@ -46,6 +46,7 @@ this.$timePicker = $('[data-timepicker]', this.$el) this.hasDate = !!this.$datePicker.length this.hasTime = !!this.$timePicker.length + this.ignoreTimezone = this.$el.get(0).hasAttribute('data-ignore-timezone') this.initRegion() @@ -292,6 +293,12 @@ if (!this.timezone) { this.timezone = 'UTC' } + + // Set both timezones to UTC to disable converting between them + if (this.ignoreTimezone) { + this.appTimezone = 'UTC' + this.timezone = 'UTC' + } } DatePicker.prototype.getLang = function(name, defaultValue) { diff --git a/modules/system/assets/ui/storm-min.js b/modules/system/assets/ui/storm-min.js index 26e2835b7..a53f20b12 100644 --- a/modules/system/assets/ui/storm-min.js +++ b/modules/system/assets/ui/storm-min.js @@ -2861,6 +2861,7 @@ this.$datePicker=$('[data-datepicker]',this.$el) this.$timePicker=$('[data-timepicker]',this.$el) this.hasDate=!!this.$datePicker.length this.hasTime=!!this.$timePicker.length +this.ignoreTimezone=this.$el.get(0).hasAttribute('data-ignore-timezone') this.initRegion() if(this.hasDate){this.initDatePicker()} if(this.hasTime){this.initTimePicker()} @@ -2923,7 +2924,9 @@ DatePicker.prototype.initRegion=function(){this.locale=$('meta[name="backend-loc this.timezone=$('meta[name="backend-timezone"]').attr('content') this.appTimezone=$('meta[name="app-timezone"]').attr('content') if(!this.appTimezone){this.appTimezone='UTC'} -if(!this.timezone){this.timezone='UTC'}} +if(!this.timezone){this.timezone='UTC'} +if(this.ignoreTimezone){this.appTimezone='UTC' +this.timezone='UTC'}} DatePicker.prototype.getLang=function(name,defaultValue){if($.oc===undefined||$.oc.lang===undefined){return defaultValue} return $.oc.lang.get(name,defaultValue)} DatePicker.DEFAULTS={minDate:null,maxDate:null,format:null,yearRange:10,firstDay:0} @@ -2989,7 +2992,7 @@ FilterWidget.prototype.getPopoverTemplate=function(){return' type="text" \ name="search" \ autocomplete="off" \ - class="filter-search-input form-control icon search" \ + class="filter-search-input form-control icon search popup-allow-focus" \ data-request="{{ optionsHandler }}" \ data-load-indicator-opaque \ data-load-indicator \ @@ -3168,7 +3171,7 @@ FilterWidget.prototype.getPopoverDateTemplate=function(){return' type="text" \ name="date" \ value="{{ date }}" \ - class="form-control align-right" \ + class="form-control align-right popup-allow-focus" \ autocomplete="off" \ placeholder="{{ date_placeholder }}" /> \ \ @@ -3194,7 +3197,7 @@ FilterWidget.prototype.getPopoverRangeTemplate=function(){return' type="text" \ name="date" \ value="{{ date }}" \ - class="form-control align-right" \ + class="form-control align-right popup-allow-focus" \ autocomplete="off" \ placeholder="{{ after_placeholder }}" /> \ \