mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-29 12:39:45 +00:00
resolve conflict
This commit is contained in:
parent
04dae52a6c
commit
2e981987f2
@ -110,7 +110,7 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
|||||||
if (event.type === "VEVENT") {
|
if (event.type === "VEVENT") {
|
||||||
let startDate = eventDate(event, "start");
|
let startDate = eventDate(event, "start");
|
||||||
let endDate;
|
let endDate;
|
||||||
|
// console.log("\nevent="+JSON.stringify(event))
|
||||||
if (typeof event.end !== "undefined") {
|
if (typeof event.end !== "undefined") {
|
||||||
endDate = eventDate(event, "end");
|
endDate = eventDate(event, "end");
|
||||||
} else if (typeof event.duration !== "undefined") {
|
} else if (typeof event.duration !== "undefined") {
|
||||||
@ -212,8 +212,9 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
|||||||
pastLocal = pastMoment.subtract(past.getTimezoneOffset(), "minutes").toDate();
|
pastLocal = pastMoment.subtract(past.getTimezoneOffset(), "minutes").toDate();
|
||||||
futureLocal = futureMoment.subtract(future.getTimezoneOffset(), "minutes").toDate();
|
futureLocal = futureMoment.subtract(future.getTimezoneOffset(), "minutes").toDate();
|
||||||
}
|
}
|
||||||
const dates = rule.between(pastLocal, futureLocal, true, limitFunction);
|
|
||||||
|
|
||||||
|
const dates = rule.between(pastLocal, futureLocal, true, limitFunction);
|
||||||
|
// console.log("title="+event.summary.val+" dates="+JSON.stringify(dates))
|
||||||
// The "dates" array contains the set of dates within our desired date range range that are valid
|
// The "dates" array contains the set of dates within our desired date range range that are valid
|
||||||
// for the recurrence rule. *However*, it's possible for us to have a specific recurrence that
|
// for the recurrence rule. *However*, it's possible for us to have a specific recurrence that
|
||||||
// had its date changed from outside the range to inside the range. For the time being,
|
// had its date changed from outside the range to inside the range. For the time being,
|
||||||
@ -242,42 +243,50 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
|||||||
let showRecurrence = true;
|
let showRecurrence = true;
|
||||||
|
|
||||||
startDate = moment(date);
|
startDate = moment(date);
|
||||||
|
// console.log("now timezone="+ moment.tz.guess());
|
||||||
// whether we need to adjust for RRULE returning the wrong date, with the right time (forward of URC timezones)
|
// whether we need to adjust for RRULE returning the wrong date, with the right time (forward of URC timezones)
|
||||||
let adjustHours = 0;
|
let adjustDays = 0;
|
||||||
// if a timezone was specified
|
// if a timezone was specified
|
||||||
if (!event.start.tz) {
|
if (!event.start.tz) {
|
||||||
// guess at one
|
|
||||||
event.start.tz = moment.tz.guess();
|
event.start.tz = moment.tz.guess();
|
||||||
}
|
}
|
||||||
// if there is a timezone
|
// console.log("tz="+event.start.tz)
|
||||||
if (event.start.tz) {
|
if (event.start.tz) {
|
||||||
// if it contains a space, it is windows,
|
// if this is a windows timezone
|
||||||
if (event.start.tz.indexOf(" ") > 0) {
|
if (event.start.tz.indexOf(" ") > 0) {
|
||||||
// get the IANA name string from hash
|
// use the lookup table to get theIANA name as moment and date don't know MS timezones
|
||||||
event.start.tz = getIanaTZFromMS(event.start.tz);
|
let tz = getIanaTZFromMS(event.start.tz);
|
||||||
|
// watch out for unregistered windows timezone names
|
||||||
|
// if we had a successfule lookup
|
||||||
|
if (tz) {
|
||||||
|
// change the timezone to the IANA name
|
||||||
|
event.start.tz = getIanaTZFromMS(event.start.tz);
|
||||||
|
// console.log("corrected timezone="+event.start.tz)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// get the offset of the start date/time
|
// get the start time in that timezone
|
||||||
let mms = moment.tz(moment(event.start), event.start.tz).utcOffset();
|
let mms = moment.tz(moment(event.start), event.start.tz).utcOffset();
|
||||||
// get the specified recurring date/time in that timezone
|
// console.log("ms offset="+mms)
|
||||||
|
// get the specified date in that timezone
|
||||||
let mm = moment.tz(moment(date), event.start.tz);
|
let mm = moment.tz(moment(date), event.start.tz);
|
||||||
// and its offset
|
|
||||||
let mmo = mm.utcOffset();
|
let mmo = mm.utcOffset();
|
||||||
|
// console.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 > 0) {
|
||||||
// get the hour for the recurring date/time
|
|
||||||
let h = parseInt(mm.format("H"));
|
let h = parseInt(mm.format("H"));
|
||||||
// check if the event time is less than the offset
|
// check if the event time is less than the offset
|
||||||
if (h > 0 && h < mmo / 60) {
|
if (h > 0 && h < mmo / 60) {
|
||||||
// if so, rrule created a wrong date (utc day, oops, with utc yesterday adjusted time)
|
// if so, rrule created a wrong date (utc day, oops, with utc yesterday adjusted time)
|
||||||
// we need to fix that
|
// we need to fix that
|
||||||
adjustHours = 24;
|
adjustDays = 24;
|
||||||
|
// console.log("adjusting date")
|
||||||
}
|
}
|
||||||
// did the daylight savings offset change from start to now?
|
|
||||||
// fix it
|
|
||||||
if (mmo > mms) {
|
if (mmo > mms) {
|
||||||
adjustHours += 1;
|
adjustDays += 1;
|
||||||
|
// console.log("adjust up 1 hour dst change")
|
||||||
} else if (mmo < mms) {
|
} else if (mmo < mms) {
|
||||||
adjustHours -= 1;
|
adjustDays -= 1;
|
||||||
|
//console.log("adjust down 1 hour dst change")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -295,6 +304,8 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
|||||||
showRecurrence = false;
|
showRecurrence = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//console.log("duration="+duration)
|
||||||
|
|
||||||
endDate = moment(parseInt(startDate.format("x")) + duration, "x");
|
endDate = moment(parseInt(startDate.format("x")) + duration, "x");
|
||||||
if (startDate.format("x") === endDate.format("x")) {
|
if (startDate.format("x") === endDate.format("x")) {
|
||||||
endDate = endDate.endOf("day");
|
endDate = endDate.endOf("day");
|
||||||
@ -316,8 +327,8 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
|||||||
addedEvents++;
|
addedEvents++;
|
||||||
newEvents.push({
|
newEvents.push({
|
||||||
title: recurrenceTitle,
|
title: recurrenceTitle,
|
||||||
startDate: (adjustHours ? startDate.subtract(adjustHours, "hours") : startDate).format("x"),
|
startDate: (adjustDays ? startDate.subtract(adjustDays, "hours") : startDate).format("x"),
|
||||||
endDate: (adjustHours ? endDate.subtract(adjustHours, "hours") : endDate).format("x"),
|
endDate: (adjustDays ? endDate.subtract(adjustDays, "hours") : endDate).format("x"),
|
||||||
fullDayEvent: isFullDayEvent(event),
|
fullDayEvent: isFullDayEvent(event),
|
||||||
recurringEvent: true,
|
recurringEvent: true,
|
||||||
class: event.class,
|
class: event.class,
|
||||||
@ -332,7 +343,7 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
|||||||
} else {
|
} else {
|
||||||
// Single event.
|
// Single event.
|
||||||
const fullDayEvent = isFacebookBirthday ? true : isFullDayEvent(event);
|
const fullDayEvent = isFacebookBirthday ? true : isFullDayEvent(event);
|
||||||
|
// console.log("full day event")
|
||||||
if (includePastEvents) {
|
if (includePastEvents) {
|
||||||
// Past event is too far in the past, so skip.
|
// Past event is too far in the past, so skip.
|
||||||
if (endDate < past) {
|
if (endDate < past) {
|
||||||
@ -365,6 +376,7 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
|||||||
}
|
}
|
||||||
// if the start and end are the same, then make end the 'end of day' value (start is at 00:00:00)
|
// if the start and end are the same, then make end the 'end of day' value (start is at 00:00:00)
|
||||||
if (fullDayEvent && startDate.format("x") === endDate.format("x")) {
|
if (fullDayEvent && startDate.format("x") === endDate.format("x")) {
|
||||||
|
//console.log("end same as start")
|
||||||
endDate = endDate.endOf("day");
|
endDate = endDate.endOf("day");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user