• 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 in relative mode, shows 1 less day than expected

Scheduled Pinned Locked Moved Troubleshooting
2 Posts 1 Posters 793 Views 1 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
    last edited by Feb 13, 2019, 12:06 AM

    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

    How to add modules

    learning how to use browser developers window for css changes

    1 Reply Last reply Reply Quote 0
    • S Offline
      sdetweil
      last edited by Feb 13, 2019, 12:49 PM

      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

      How to add modules

      learning how to use browser developers window for css changes

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