• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
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.

Default Calendar module // request to show events only if start date > today + 2 days

Scheduled Pinned Locked Moved Development
10 Posts 3 Posters 2.5k Views 4 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.
  • B Offline
    bolish
    last edited by bolish Feb 3, 2019, 6:31 PM Feb 3, 2019, 6:31 PM

    Hi,

    Is there a way to make the calendar events show only when they are after after a certain number of days?

    Let’s say, do not show an event if date is < today + 2 days.

    I tried to use the ExcludedEvents + FilterBy “until” but didn’t worked.
    Also looked at modifying the calendar or fetcher.js but sounds like a bad idea…

    Regards

    Regards

    1 Reply Last reply Reply Quote 0
    • G Offline
      ganget
      last edited by Feb 3, 2019, 7:43 PM

      you can try to use this

      			config: {
      				fetchInterval: 60000,
      				maximumEntries: 15, // you can also change this to 2 to have the first 2 entries only
      				maximumNumberOfDays: 365, //change this to 2 it should limit the max number of days in the future to 2
      				animationSpeed: 0,
      				fadePoint: 3,
      				timeFormat: 'absolute',
      				dateformat: 'dddd Do MMM',
      				urgency: 3,
      				calendars:
      

      Let me know if it works out

      1 Reply Last reply Reply Quote 0
      • B Offline
        bolish
        last edited by Feb 3, 2019, 7:55 PM

        hi @ganget
        Thanks for prompt reply.

        Maybe there is a misunderstanding as I can’t figure out what is forcing the calendar to start in 2 days only in your calendar.

        Your code will allow me to block max entries to 15 or to a certain number of days (365 or 2 or whatever) but not allow me to hide event from today + the day after.

        Let me try to rephrase my need : I need the calendar to hide (to not show) the 2 first days of event.

        Or maybe I missed something in your code.

        1 Reply Last reply Reply Quote 0
        • G Offline
          ganget
          last edited by ganget Feb 3, 2019, 8:35 PM Feb 3, 2019, 8:30 PM

          No you did not miss anything in my code i just misinterpreted your question. Sorry for that here is another idea that could work. Maybe the continue statement will help you to skip the 2 first entries of the calendar. You will need to change the module code for that to work.

          1 Reply Last reply Reply Quote 0
          • B Offline
            bolish
            last edited by Feb 3, 2019, 9:34 PM

            @ganget
            no problem. thanks for the idea.
            I was thinking about modifying the module code to change “today’s” date into “today’s date +2” but can’t yet figure out how too.

            S 1 Reply Last reply Feb 3, 2019, 10:04 PM Reply Quote 0
            • S Away
              sdetweil @bolish
              last edited by sdetweil Feb 4, 2019, 12:39 PM Feb 3, 2019, 10:04 PM

              @bolish

              the existing code is.

              	if (event.startDate >= new Date()) {
              

              and ideas on how to add days to today or whatever

              https://stackoverflow.com/questions/3818193/how-to-add-number-of-days-to-todays-date

              Sam

              How to add modules

              learning how to use browser developers window for css changes

              1 Reply Last reply Reply Quote 0
              • B Offline
                bolish
                last edited by Feb 4, 2019, 8:21 AM

                @sdetweil
                Thanks, I will give it a try this evening and keep you guys posted.

                1 Reply Last reply Reply Quote 0
                • B Offline
                  bolish
                  last edited by Feb 4, 2019, 8:23 PM

                  @sdetweil
                  Hi again, I just tried by modifying the createEventList “today” and “now” variable, but it didn’t work…

                  createEventList: function () {
                  		var events = [];
                  		var someDate = new Date();
                  		var numberOfDaysToAdd = 6;
                  		someDate.setDate(someDate.getDate() + numberOfDaysToAdd);
                  		var today = moment(someDate).startOf("day");
                  		var now = someDate;
                  		for (var c in this.calendarData) {
                  
                  S 1 Reply Last reply Feb 5, 2019, 1:16 PM Reply Quote 0
                  • S Away
                    sdetweil @bolish
                    last edited by sdetweil Feb 5, 2019, 9:36 PM Feb 5, 2019, 1:16 PM

                    @bolish close…

                    the existing loop takes ALL events, just checking to see if each event is TODAY (sets a flag)

                    to eliminate them you need one more test (in addition to the rest of your code above)

                    		var someDate = new Date();
                    		var numberOfDaysToAdd = 6;
                    		someDate.setDate(someDate.getDate() + numberOfDaysToAdd);
                    		var today = moment(someDate).startOf("day");
                    	//var today = moment().startOf("day");
                    		for (var c in this.calendarData) {
                    			var calendar = this.calendarData[c];
                    			for (var e in calendar) {
                    				var event = calendar[e];
                                                     // if event happens further away than x number of days (6 in this sample)
                    				if(event.startDate>= today) {    < ------
                    					if(this.config.hidePrivate) {
                    						if(event.class === "PRIVATE") {
                    							  // do not add the current event, skip it
                    							  continue;
                    						}
                    					}
                    					event.url = c;
                    					event.today = event.startDate >= today && event.startDate < (today + 24 * 60 * 60 * 1000);
                    					events.push(event);
                    				}
                    			}
                    		}
                    

                    Sam

                    How to add modules

                    learning how to use browser developers window for css changes

                    1 Reply Last reply Reply Quote 1
                    • B Offline
                      bolish
                      last edited by Feb 5, 2019, 7:54 PM

                      @sdetweil
                      Works like a charm.
                      Thank you very much, I’ve learnt something thanks to you and appreciated your support for debug.
                      See you around.

                      1 Reply Last reply Reply Quote 0
                      • 1 / 1
                      1 / 1
                      • First post
                        1/10
                        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