mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-29 12:39:45 +00:00
fix time offset calcs for any timezone
This commit is contained in:
parent
844a59d880
commit
5d2f706c32
@ -300,8 +300,8 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
|||||||
addedEvents++;
|
addedEvents++;
|
||||||
newEvents.push({
|
newEvents.push({
|
||||||
title: recurrenceTitle,
|
title: recurrenceTitle,
|
||||||
startDate: (adjustDays ? startDate.subtract(adjustDays, "hours") : startDate).format("x"),
|
startDate: (adjustDays ? (adjustDays > 0 ? startDate.add(adjustDays, "hours") : startDate.subtract(Math.abs(adjustDays), "hours")) : startDate).format("x"),
|
||||||
endDate: (adjustDays ? endDate.subtract(adjustDays, "hours") : endDate).format("x"),
|
endDate: (adjustDays ? (adjustDays > 0 ? endDate.add(adjustDays, "hours") : endDate.subtract(Math.abs(adjustDays), "hours")) : endDate).format("x"),
|
||||||
fullDayEvent: isFullDayEvent(event),
|
fullDayEvent: isFullDayEvent(event),
|
||||||
recurringEvent: true,
|
recurringEvent: true,
|
||||||
class: event.class,
|
class: event.class,
|
||||||
@ -357,8 +357,8 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
|||||||
// Every thing is good. Add it to the list.
|
// Every thing is good. Add it to the list.
|
||||||
newEvents.push({
|
newEvents.push({
|
||||||
title: title,
|
title: title,
|
||||||
startDate: (adjustDays ? startDate.subtract(adjustDays, "hours") : startDate).format("x"),
|
startDate: (adjustDays ? (adjustDays > 0 ? startDate.add(adjustDays, "hours") : startDate.subtract(Math.abs(adjustDays), "hours")) : startDate).format("x"),
|
||||||
endDate: (adjustDays ? endDate.subtract(adjustDays, "hours") : endDate).format("x"),
|
endDate: (adjustDays ? (adjustDays > 0 ? endDate.add(adjustDays, "hours") : endDate.subtract(Math.abs(adjustDays), "hours")) : endDate).format("x"),
|
||||||
fullDayEvent: fullDayEvent,
|
fullDayEvent: fullDayEvent,
|
||||||
class: event.class,
|
class: event.class,
|
||||||
location: location,
|
location: location,
|
||||||
@ -435,7 +435,7 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
|||||||
}
|
}
|
||||||
if (debug) Log.log("mm ofset=" + mmo + " hour=" + mm.format("H") + " event date=" + mm.toDate());
|
if (debug) Log.log("mm ofset=" + mmo + " hour=" + mm.format("H") + " event date=" + mm.toDate());
|
||||||
// if the offset is greater than 0, east of london
|
// if the offset is greater than 0, east of london
|
||||||
if (mmo > 0) {
|
if (mmo !== mms) {
|
||||||
// big offset
|
// big offset
|
||||||
if (debug) Log.log("offset");
|
if (debug) Log.log("offset");
|
||||||
let h = parseInt(mm.format("H"));
|
let h = parseInt(mm.format("H"));
|
||||||
@ -446,10 +446,10 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
|||||||
adjustHours = 24;
|
adjustHours = 24;
|
||||||
// if(debug) Log.log("adjusting date")
|
// if(debug) Log.log("adjusting date")
|
||||||
}
|
}
|
||||||
if (mmo > mms) {
|
if (Math.abs(mmo) > Math.abs(mms)) {
|
||||||
adjustHours += 1;
|
adjustHours += 1;
|
||||||
if (debug) Log.log("adjust up 1 hour dst change");
|
if (debug) Log.log("adjust up 1 hour dst change");
|
||||||
} else if (mmo < mms) {
|
} else if (Math.abs(mmo) < Math.abs(mms)) {
|
||||||
adjustHours -= 1;
|
adjustHours -= 1;
|
||||||
if (debug) Log.log("adjust down 1 hour dst change");
|
if (debug) Log.log("adjust down 1 hour dst change");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user