Closed nickloudermilk closed 1 year ago
How about it displayed on the original MMM-GoogleCalendar module? Frankly, this module doesn't parse the time of event. MMM-GoogleCalendar parses the event time, then this module use the parsed result. So, if the time is not parsed properly, maybe it might be the business of MMM-GoogleCalendar.
All day events appear correctly in the original MMM-GoogleCalendar module. Times for events that are not all day appear correctly. I.e. in the example above, "Matt out" does start at 8:00 AM local time on Tuesday.
I was able to modify the transformer added to the config so that it adjusted all day events to match my time zone. Here is an example:
eventTransformer: (e) => { e.startDate = new Date(e.start?.date || e.start?.dateTime).valueOf() e.endDate = new Date(e.end?.date || e.end?.dateTime).valueOf() e.title = e.summary e.fulldayEvent = (e.start?.date) ? true : false const oneSecond = 1000; // 1,000 milliseconds const oneMinute = oneSecond 60; const oneHour = oneMinute 60; const oneDay = oneHour 24; const timeCorrect = oneHour 6; if (e.fulldayEvent) e.startDate += timeCorrect; return e }
In my case my timeCorrect = oneHour * 6 because I am UTC -6.
The eventTransformer arrow function has a bug in it. When you create a date without a time, you will get potentially different results for the default time. For example new Date('01/01/2023') sets the timezone to my local, but the Google date format new Date('2023-01-01') sets it to UTC. So, I corrected this as follows:
eventTransformer: (e) => {
e.startDate = new Date(e.start?.date ? e.start.date + ' 00:00' : null || e.start?.dateTime).valueOf()
e.endDate = new Date(e.end?.date ? e.end.date + ' 00:00' : null || e.end?.dateTime).valueOf()
e.title = e.summary
e.fulldayEvent = (e.start?.date) ? true : false
return e
}
@ccortellinijc That is a great point! I never have realized new Date('2023-01-01')
and new Date('01/01/2023')
have different result!
Anyway I'm waiting Temporal
API is introduced in real JS world. JS default Date
object is not perfect to handle calendar things. After Temporal API, I'll rewrite the whole module with it.
I'll change the tip with yours in README.md in the next update. Thanks.
used @ccortellinijc tip:
This fixed multi-day events. Single day events now display as regular events starting at 12:00 AM. @ccortellinijc was that the effect you had as well or am I missing content?
@ruralguru
The root of this issue would be caused by this - MMM-GoogleCalendar
doesn't respect the default calendar
module's broadcasting event notification format.
fullDayEvent
- missing.start.date
, end.date
, start.dateTime
and end.dateTime
are used instead of startDate
and endDate
on fulldayevent
, but original calendar
module doesn't have them, not compatible so we need some converting like this tip mentioned.The easy and conventional way to solve this issue might be; Ask the developer of MMM-GoogleCalendar
to edit that format to be compatible with de-facto default event format.
I was struggling to see the event structure. Thank you for noting the deviations. I suspected the ? Was an inquiry, just couldn't find the start.date reference rather than startDate. I was thinking of requesting or forking the google calendar, but my time is limited such that I can't support my request. I try to ask questions that lead to me at least supporting the answer.
Check #31
When all day events are pulled from MMM-GoogleCalendar broadcast, they appear to start the prior day at 7 PM (5 hours before their actual starting time of midnight). I am in a time zone that is exactly UTC-5.
MMM-GoogleCalendar Config:
MMM-CalendarExt3 Config: