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.9k 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.
    • S Offline
      sdetweil @bolish
      last edited by sdetweil

      @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

        @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

          @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 Reply Quote 0
          • S Offline
            sdetweil @bolish
            last edited by sdetweil

            @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

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