Read the statement by Michael Teeuw here.
Calendar Module : in x days give bad value
-
Hi!
first, what a nice project this MagicMirror.I’m using the calendar module with two ical : facebook et garmin
On display, the module gives the right informations about event for today or tomorrowBut for an event in 2 days or more, it seem calculate a wrong value…
For exemple (same problem with facebook and garmin calendar) :
today is august 10.
Birthday A : august 10 - shows today
Birthday B : august 11 - shows tomorrow
Birthday C : august 12 - shows in 1 day? Show display “in 2 days”
Birthday D : august 14 - shows in 3 days? Show display “in 4 days”thanks
Sébastien -
The calculations are correct for how a computer calculates it:
Birthday A : august 10 - shows today Birthday B : august 11 - shows tomorrow Birthday C : august 12 - shows in 1 day? Show display "in 2 days" Birthday D : august 14 - shows in 3 days? Show display “in 4 days”
Calculations are done starting at the next midnight. So:
Birthday A : august 10 - shows today -- at the next midnight, it's day 0 Birthday B : august 11 - shows tomorrow -- at midnight, it will be day 0 + 1, so 'in 1 day' or 'tomorrow' Birthday C : august 12 - shows in 1 day? Show display "in 2 days" -- at midnight, it will be day 0 + 2, so 'in 2 days' Birthday D : august 14 - shows in 3 days? Show display “in 4 days” -- at midnight, it will be day 0 + 4, so 'in 4 days'
The way the calculations are done isn’t perfect, but it’s how Moment.js returns those values, based on midnight.