FIX: clone dateTime before changing timezone

This commit is contained in:
Régis Hanol 2019-06-06 11:16:58 +02:00
parent b339d67401
commit c131903e56
1 changed files with 9 additions and 10 deletions

View File

@ -201,14 +201,13 @@
}
function _createDateTimeRange(dateTime, timezone) {
const startRange = dateTime.tz(timezone).format("LLL");
const separator = "→";
const endRange = dateTime
.add(24, "hours")
.tz(timezone)
.format("LLL");
const dt = moment(dateTime).tz(timezone);
return `${startRange} ${separator} ${endRange}`;
return [
dt.format("LLL"),
"→",
dt.add(24, "hours").format("LLL"),
].join(" ");
}
function _generatePreviews(dateTime, displayedTimezone, options) {
@ -222,7 +221,7 @@
timezone: watchingUserTimezone,
current: true,
dateTime: options.time
? dateTime.tz(watchingUserTimezone).format("LLL")
? moment(dateTime).tz(watchingUserTimezone).format("LLL")
: _createDateTimeRange(dateTime, watchingUserTimezone)
});
@ -249,7 +248,7 @@
previewedTimezones.push({
timezone,
dateTime: options.time
? dateTime.tz(timezone).format("LLL")
? moment(dateTime).tz(timezone).format("LLL")
: _createDateTimeRange(dateTime, timezone)
});
});
@ -258,7 +257,7 @@
previewedTimezones.push({
timezone: "Etc/UTC",
dateTime: options.time
? dateTime.tz("Etc/UTC").format("LLL")
? moment(dateTime).tz("Etc/UTC").format("LLL")
: _createDateTimeRange(dateTime, "Etc/UTC")
});
}