MagicMirror² v2.6.0 is available! For more information about this release, check out this topic.

module calendar showing full day events one day to long



  • Hi,

    I use the standard calendar module and it works to my expactations. Only one thing is strange: when I enter a full day event in my google calendar, no matter if 1 day or multiple days, it will be displayed to be on day longer on the MagicMirror.
    So a full day event for today (12th october) would be display for today and tomorrow (12th to 13th october). Does anyone know why?

    Regards,
    Anduril


  • Module Developer

    @andurii
    I’m not sure, but different timezone setting between your mirrors and Google calendar could cause that kind.



  • I just checked, my google account is set to timezone Berlin and my raspberry is too (set in raspi-config). Is there an additional setting for the magicmirror?





  • Per @Nilnik 's comment, have a look at that thread. I was having the same issue as well (that’s the thread I had started). Ultimately, it came down to adding the showEnd: false, to the config for the calendar.

    timeFormat: 'absolute',
    showEnd: false,
    


  • thanks for your comments @Nilnik @StrIIker
    This solves the problem, but that’s not a solution 🙂
    It’s more a kind of a hack to hide the problem. I use it to show my daily apointments inclunding multiday ones. Having the mirror show only e.g. my holiday started 5 days ago without a duration is kind of useless.
    As I’m not the only one having that, did anyone ever looked into deeply? Where does this start? Is it a problem with timezones incorrectly submitted by google calendar? Is it a problem of fetching in MM?
    If anyone has a guess, I would greatly appreciate any help. When I know where to look, I might also try to search the root of that bug.
    Are there some people using it and where it works correctly? Or is simply no one using this module at all (without that hack)?



  • @andurii Without looking close on it, I could imagine it’s a matter of timestamps being interpreted by the moment() function.
    If a full date event creates two timestamps that translate to “Today 0:00:000 - Tomorrow 0:00:000” then it would include tomorrow in the MM translation.
    However, I’m not sure about this. Will check into it as well. Interesting topic.

    And you’re right, showEnd: false is not more than a workaround.



  • Here’s the relevant code:

    					} else {
    						/* Check to see if the user displays absolute or relative dates with their events
    						* Also check to see if an event is happening within an 'urgency' time frameElement
    						* For example, if the user set an .urgency of 7 days, those events that fall within that
    						* time frame will be displayed with 'in xxx' time format or moment.fromNow()
    						*
    						* Note: this needs to be put in its own function, as the whole thing repeats again verbatim
    						*/
    						if (this.config.timeFormat === "absolute") {
    							if ((this.config.urgency > 1) && (event.startDate - now < (this.config.urgency * oneDay))) {
    								// This event falls within the config.urgency period that the user has set
    								timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").fromNow());
    							} else {
    								timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").format(this.config.fullDayEventDateFormat));
    							}
    						} else {
    							timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").fromNow());
    						}
    					}
    					if(this.config.showEnd){
    						timeWrapper.innerHTML += "-" ;
    						timeWrapper.innerHTML += this.capFirst(moment(event.endDate  , "x").format(this.config.fullDayEventDateFormat));
    					}
    
    

    You can see in the end, that an end to the date is created if showEnd is true. So as far as I can see it, it all comes down to what

    event.endDate
    

    generates.



  • @AnduriI I agree that this is a kludge to get the calendar working. I had tried out MMM-MyCalendar which didn’t appear to have this issue (all day events like holidays and birthdays displayed the correct date). It’s a great module BUT, I decided not to use it because I can’t change the colors of the calendars and I could not use a custom icon for different calendars. For example, on my calendar, I have three calendars (US Holidays - white, Birthday calendar - purple with cake icon, and appointments - green). It helps to highlight the different events showing up in the list. I didn’t reach out to the module developer to request this yet. Give it a look, it might be what you are looking for.

    Unfortunately Magic Mirror has issues which need a kludge hack to resolve (I need to cron a restart of the Magic Mirror application every 5 hours otherwise it goes black (not a screen saver or power saving thing). This has been present for since at least the previous build. Still, I love the Magic Mirror platform and the community is amazing! I am grateful every time I come here and see people helping each other out…



  • Well this MAY be it. calendarfetcher.js

    					if (typeof event.end !== "undefined") {
    						endDate = eventDate(event, "end");
    					} else if(typeof event.duration !== "undefined") {
    						dur=moment.duration(event.duration);
    						endDate = startDate.clone().add(dur);
    
    

    if duration is EXACTLY 24h for a full day event, we would land up at the next day with this .add-function
    You COULD try the following:

    Go into calendarfetcher.js and change in line 96

    endDate = startDate.clone().add(dur);
    

    to something like

    endDate = startDate.clone().add(dur-10000);
    

    I can’t do it, I’m at work and REALLY need to go back to it now 🙂

    EDIT: …well, I needed to try. That’s not the solution. But it should be somewhere in that file 🙂