From: Marcel Werk Date: Wed, 28 Dec 2016 17:48:15 +0000 (+0100) Subject: Fixed ignore-timezone data-attribute X-Git-Tag: 3.0.0_RC_3~17 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=411e8c271fbc17a4856e2910b7c298bc2b8a589e;p=GitHub%2FWoltLab%2FWCF.git Fixed ignore-timezone data-attribute --- diff --git a/com.woltlab.wcf/templates/__messageFormPoll.tpl b/com.woltlab.wcf/templates/__messageFormPoll.tpl index ba43b177b5..c7f549086f 100644 --- a/com.woltlab.wcf/templates/__messageFormPoll.tpl +++ b/com.woltlab.wcf/templates/__messageFormPoll.tpl @@ -41,7 +41,7 @@
- + {if $errorField == 'pollEndTime'} {lang}wcf.poll.endTime.error.{@$errorType}{/lang} diff --git a/com.woltlab.wcf/templates/__messageFormPollInline.tpl b/com.woltlab.wcf/templates/__messageFormPollInline.tpl index 3f7004b79a..b0f9a5450e 100644 --- a/com.woltlab.wcf/templates/__messageFormPollInline.tpl +++ b/com.woltlab.wcf/templates/__messageFormPollInline.tpl @@ -38,7 +38,7 @@
- +
diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Date/Picker.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Date/Picker.js index 24ded4cb1b..244bcb1c5f 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Date/Picker.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Date/Picker.js @@ -50,6 +50,7 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment var isDateTime = (elAttr(element, 'type') === 'datetime'); var isTimeOnly = (isDateTime && elDataBool(element, 'time-only')); var disableClear = elDataBool(element, 'disable-clear'); + var ignoreTimezone = isDateTime && elDataBool(element, 'ignore-timezone'); elData(element, 'is-date-time', isDateTime); elData(element, 'is-time-only', isTimeOnly); @@ -63,6 +64,19 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment date.setHours(tmp[0], tmp[1]); } else { + if (ignoreTimezone) { + var timezoneOffset = new Date(value).getTimezoneOffset(); + var timezone = (timezoneOffset > 0) ? '-' : '+'; // -120 equals GMT+0200 + timezoneOffset = Math.abs(timezoneOffset); + var hours = (Math.floor(timezoneOffset / 60)).toString(); + var minutes = (timezoneOffset % 60).toString(); + timezone += (hours.length == 2) ? hours : '0' + hours; + timezone += ':'; + timezone += (minutes.length == 2) ? minutes : '0' + minutes; + + value = value.replace(/[+-][0-9]{2}:[0-9]{2}$/, timezone); + } + date = new Date(value); } @@ -111,6 +125,9 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment if (isTimeOnly) { shadowElement.value = DateUtil.format(date, 'H:i'); } + else if (ignoreTimezone) { + shadowElement.value = DateUtil.format(date, 'Y-m-dTH:i:s'); + } else { shadowElement.value = DateUtil.format(date, (isDateTime) ? 'c' : 'Y-m-d'); } @@ -170,6 +187,7 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment isDateTime: isDateTime, isEmpty: isEmpty, isTimeOnly: isTimeOnly, + ignoreTimezone: ignoreTimezone, onClose: null }); @@ -483,6 +501,10 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment value = DateUtil.formatTime(date); shadowValue = DateUtil.format(date, 'H:i'); } + else if (data.ignoreTimezone) { + value = DateUtil.formatDateTime(date); + shadowValue = DateUtil.format(date, 'Y-m-dTH:i:s'); + } else { value = DateUtil.formatDateTime(date); shadowValue = DateUtil.format(date, 'c'); @@ -712,7 +734,18 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment elData(element, 'value', date.getTime()); element.value = DateUtil['formatDate' + (data.isDateTime ? 'Time' : '')](date); - data.shadow.value = DateUtil.format(date, (data.isDateTime ? 'c' : 'Y-m-d')); + var format = ''; + if (data.ignoreTimezone) { + format = 'Y-m-dTH:i:s'; + } + else if (data.isDateTime) { + format = 'c'; + } + else { + format = 'Y-m-d'; + } + + data.shadow.value = DateUtil.format(date, format); }, /**