MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    module calendar showing full day events one day to long

    Scheduled Pinned Locked Moved Unsolved Troubleshooting
    19 Posts 5 Posters 9.4k Views 6 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A Offline
      AnduriI
      last edited by

      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

      ? lavolp3L 2 Replies Last reply Reply Quote 0
      • ? Offline
        A Former User @AnduriI
        last edited by

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

        1 Reply Last reply Reply Quote 0
        • A Offline
          AnduriI
          last edited by

          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?

          1 Reply Last reply Reply Quote 0
          • N Offline
            Nilnik Project Sponsor
            last edited by

            Hello! Check this link: https://forum.magicmirror.builders/topic/8856/calendar-module-1-day-error/3

            1 Reply Last reply Reply Quote 1
            • S Offline
              StrIIker
              last edited by

              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,
              
              1 Reply Last reply Reply Quote 0
              • A Offline
                AnduriI
                last edited by

                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)?

                lavolp3L 1 Reply Last reply Reply Quote 0
                • lavolp3L Offline
                  lavolp3 Module Developer @AnduriI
                  last edited by

                  @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.

                  How to troubleshoot modules
                  MMM-soccer v2, MMM-AVStock

                  1 Reply Last reply Reply Quote 0
                  • lavolp3L Offline
                    lavolp3 Module Developer
                    last edited by

                    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.

                    How to troubleshoot modules
                    MMM-soccer v2, MMM-AVStock

                    1 Reply Last reply Reply Quote 0
                    • S Offline
                      StrIIker
                      last edited by

                      @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…

                      lavolp3L 1 Reply Last reply Reply Quote 0
                      • lavolp3L Offline
                        lavolp3 Module Developer
                        last edited by lavolp3

                        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 :-)

                        How to troubleshoot modules
                        MMM-soccer v2, MMM-AVStock

                        1 Reply Last reply Reply Quote 0
                        • lavolp3L Offline
                          lavolp3 Module Developer @StrIIker
                          last edited by

                          @striiker
                          I need to disagree here.
                          MagicMirror does not need kludge hacks!
                          It needs development!

                          I am 100% sure your 5-hours-restart-hack can be solved without the workaround.

                          How to troubleshoot modules
                          MMM-soccer v2, MMM-AVStock

                          S 1 Reply Last reply Reply Quote 0
                          • S Offline
                            StrIIker @lavolp3
                            last edited by StrIIker

                            @lavolp3 said in module calendar showing full day events one day to long:

                            @striiker
                            I need to disagree here.
                            MagicMirror does not need kludge hacks!
                            It needs development!

                            I am 100% sure your 5-hours-restart-hack can be solved without the workaround.

                            I absolutely agree that it needs development. Unfortunately that’s outside of my realm of expertise (and others who have these types of issues). In the absence of someone actively developing a solution to a defect which should be widely known (I have had this crash happen on multiple fresh, new base installs) we are left with using what we can to work around the issues.

                            The only responses I had to my query around the crashing was from others who had this happen and one person who suggested the cron restart. There was another post by someone else with the same issue as well.

                            Beggars can’t be choosers and I’m not complaining about this. I am hopeful that these issues will get addressed some day but in the mean time, here we are.

                            lavolp3L 1 Reply Last reply Reply Quote 0
                            • lavolp3L Offline
                              lavolp3 Module Developer @StrIIker
                              last edited by

                              @striiker I guess this forum got too crowded to have everything solved properly. I feel you.

                              How to troubleshoot modules
                              MMM-soccer v2, MMM-AVStock

                              1 Reply Last reply Reply Quote 0
                              • lavolp3L Offline
                                lavolp3 Module Developer @AnduriI
                                last edited by

                                @andurii OK I found a way to properly deal with one-day events. Will send a PR to the develop branch.
                                If you want to include it already:

                                Exchange the if-clause starting at line 292 with this.

                                					if(this.config.showEnd){
                                						if(event.endDate - event.startDate > oneDay) { 
                                							timeWrapper.innerHTML += "-" ;
                                							timeWrapper.innerHTML += this.capFirst(moment(event.endDate  , "x").format(this.config.fullDayEventDateFormat));
                                						}
                                					}
                                

                                BEWARE OF CHANGING THE MODULE FILES THEMSELVES.
                                Only do it if you know what you’re doing.
                                (You’re not breaking anything irreversibly however)

                                This only shows the end date for a more-than-one-day-full-day-event.
                                However, still a workaround. Still searching into the problem itself

                                How to troubleshoot modules
                                MMM-soccer v2, MMM-AVStock

                                1 Reply Last reply Reply Quote 1
                                • A Offline
                                  AnduriI
                                  last edited by

                                  @lavolp3 thank’s a lot man, you are much faster and way more skilled than me :-)
                                  Just a little discussion: your code only adds the if clause to check if it’s longer than a day to prevent single full day events to be displayed as two day. But what about a multi day event beeing displayed one day to long (which is also happening right now)?

                                  lavolp3L 1 Reply Last reply Reply Quote 0
                                  • lavolp3L Offline
                                    lavolp3 Module Developer @AnduriI
                                    last edited by

                                    @andurii
                                    Yeah that’s what is still missing and why i said this is still only some type of workaround.
                                    However, the if-clause will be needed in the end because for a full one-day event you do not want to be shown an endDate. As soon as the full-day-event is longer than one day, you may want it again.
                                    E.g.
                                    Mario’s birthday Nov 16th
                                    (and NOT Nov 16th - Nov 16th)
                                    Luigi’s Holiday Nov 16th - Nov 23rd

                                    What you’re pointing at is the root cause and it lies somewhere else. I’m sure it can be solved. Give me one weekend ;-)

                                    How to troubleshoot modules
                                    MMM-soccer v2, MMM-AVStock

                                    1 Reply Last reply Reply Quote 0
                                    • lavolp3L Offline
                                      lavolp3 Module Developer
                                      last edited by lavolp3

                                      So I guess I have found a “solution”.
                                      This is in fact a systemic problem.

                                      A full day event is given by the ical source as starting at 0:00 on a day and ending at 0:00, but one day ahead. The duration is exactly a multiple of 24h.

                                      There is a one-liner as workaround, but I’d invite everyone to find a more gentle solution.

                                      The workaround: subtract one second from the endDate time:
                                      Include this line into calendar.js just at the beginning of the if clause in line 262:

                                      event.endDate -= 1000;
                                      

                                      So it looks like this:

                                      				if (event.fullDayEvent) {
                                                                              event.endDate -= 1000;
                                      					if (event.today) {
                                      

                                      This should solve the issue. It worked for me at least.

                                      How to troubleshoot modules
                                      MMM-soccer v2, MMM-AVStock

                                      A 1 Reply Last reply Reply Quote 0
                                      • A Offline
                                        AnduriI @lavolp3
                                        last edited by

                                        @lavolp3 great, your fix worked. Only thing I noticed is if the date is tomorrow it still shows ‘Tomorrow - Nov. 22’
                                        Now I still have to fiddle a few glitches in the calendar module:

                                        1. Having a event with start and end time it will be displayed like ‘in 3 days - 18:00’. It would be better to include starting time ‘in 3 days 15:00 - 18:00’
                                        2. For a ongoing event it keeps the end time, but start time gets relative for how long it still goes on ‘1 hour left - 18:00’ (hope my translation is correct, my mirror is german). Maybe this could be changed to ‘for 4 hours - 18:00’ or similiar.
                                        lavolp3L 1 Reply Last reply Reply Quote 0
                                        • lavolp3L Offline
                                          lavolp3 Module Developer @AnduriI
                                          last edited by

                                          @andurii I agree with you on both points and I’m working on it :-)
                                          Basically the implementation of showEnd is quite messed up.
                                          I’m trying to use my freshly gained JS beginner skills on this :-)

                                          Have send a PR for the fulldayevent fix and I expect this to be included in the next release.

                                          How to troubleshoot modules
                                          MMM-soccer v2, MMM-AVStock

                                          1 Reply Last reply Reply Quote 1

                                          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                          With your input, this post could be even better 💗

                                          Register Login
                                          • 1 / 1
                                          • First post
                                            Last post
                                          Enjoying MagicMirror? Please consider a donation!
                                          MagicMirror created by Michael Teeuw.
                                          Forum managed by Sam, technical setup by Karsten.
                                          This forum is using NodeBB as its core | Contributors
                                          Contact | Privacy Policy