Skip to content

Compatible with randomBrainstormer MMM GoogleCalendar

Seongnoh Sean Yi edited this page Jan 10, 2024 · 2 revisions
preProcessor: (e) => {
  if (e.startDate) return e // when event coming from default module, skip conversion.
  if (e.start?.dateTime) {
          e.startDate = new Date(e.start.dateTime).valueOf()
  } else if (e.start?.date) {
          e.startDate = new Date(`${e.start.date}T00:00:00`).valueOf()
  }
  
  if (e.end?.dateTime) {
          e.endDate = new Date(e.end.dateTime).valueOf()
  } else if (e.end?.date) {
          e.endDate = new Date(`${e.end.date}T00:00:00`).valueOf()
  }
  
  e.title = e.summary
  e.fullDayEvent = (e.start?.date) ? true : false
  return e
}

This tip doesn't consider different time zones. You should add some offset to startDate and endDate additionally to convert the event into your timezone if the calendar's timezone differs from your system.