MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord

    default calendar in relative mode, shows 1 less day than expected

    Troubleshooting
    1
    2
    465
    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
      sdetweil last edited by

      i am helping a user try to get their calendar to display properly
      he is in Norway, utc +1, calendar is in correct timezone, and his system date is also in correct timezone.
      showEnd is false, and in absolute mode shows the correct date , Feb 21, as the start date for the entry.

      however in relative mode, it says 8 days. but should be 9. (today being the 12th)
      i have been over the code a bunch today, and the ONLY place I can see any consideration for this kind of problem is to check for full day events and adjust the start of the startdate to beginning of day (00:00:00)

      but then the calc is timeWrapper.innerHTML = this.capFirst(moment(event.startDate, “x”).fromNow());

      well, NOW is current local time… so, if its using WHOLE days( truncated, not rounded), then its right, but the user sees it as 9 (21-12).

      Sam

      Create a working config
      How to add modules

      1 Reply Last reply Reply Quote 0
      • S
        sdetweil last edited by

        SO… the problem is the calculation uses the local hour to determine from now… but users see days…

        so the fix is to truncate NOW to the start of the day…, then the comparison is start of day to start of day…

        instead of this

        // uses hours/mins/seconds of now..
        timeWrapper.innerHTML = this.capFirst(moment(event.startDate, “x”).fromNow());
        

        do this

        // uses  only date, time is 00:00:00, fullday events also start at 00:00:00
        timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").from(moment().format("YYYYMMDD")));
        

        Sam

        Create a working config
        How to add modules

        1 Reply Last reply Reply Quote 1
        • 1 / 1
        • First post
          Last post
        Enjoying MagicMirror? Please consider a donation!
        MagicMirror created by Michael Teeuw.
        Forum managed by Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
        This forum is using NodeBB as its core | Contributors
        Contact | Privacy Policy