From d81f3ee2c2c6fc31cce608929822478c29c73a65 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Mon, 1 Apr 2019 12:19:09 +0200 Subject: [PATCH] FIX: improves DST support of dates when recurrence is used (#7297) --- .../discourse-local-dates.js.no-module.es6 | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/discourse-local-dates/assets/javascripts/discourse-local-dates.js.no-module.es6 b/plugins/discourse-local-dates/assets/javascripts/discourse-local-dates.js.no-module.es6 index daacf30dd30..9b5cd8cc552 100644 --- a/plugins/discourse-local-dates/assets/javascripts/discourse-local-dates.js.no-module.es6 +++ b/plugins/discourse-local-dates/assets/javascripts/discourse-local-dates.js.no-module.es6 @@ -185,8 +185,19 @@ const type = parts[1]; const diff = moment().diff(dateTime, type); const add = Math.ceil(diff + count); + const wasDST = moment(dateTime.format()).isDST(); + let dateTimeWithRecurrence = dateTime.add(add, type); + const isDST = moment(dateTimeWithRecurrence.format()).isDST(); - return dateTime.add(add, type); + if (!wasDST && isDST) { + dateTimeWithRecurrence.subtract(1, "hour"); + } + + if (wasDST && !isDST) { + dateTimeWithRecurrence.add(1, "hour"); + } + + return dateTimeWithRecurrence; } function _createDateTimeRange(dateTime, timezone) {