Bug when subtracting dates between 12 AM - 1 AM
Posted: 11 Jun 2018 20:09
I have flows that subtract two dates in order to determine the whether the current shift is A or B based on a repeating 14-day pattern.
However, if the time is between 12 AM - 1 AM, sometimes the dates do not subtract correctly.
I recreated the bug with a simplified script:
Here "days" equals only 7 days, when it should be 8. I divide by 86400000 to convert from milliseconds to days, but this error happens even if I leave the value in milliseconds, minutes, or hours then convert to # of days in a calculator by hand. I usually use a specific date like the (2018,3,4) in the example for start and getDate() for end. The error happens both ways.
If I use getDate() and manually set the time on my device to 12:59 AM, immediately at 1 AM it shows the correct number of elapsed days. I have this bug on multiple devices: tablets and a phone.
Some dates don't have this bug. For example, using May instead of March: getDate(2018,5,4) and getDate(2018,5,12). Or using 2017 instead of 2018: getDate(2017,3,4) and getDate(2017,3,12).
I used this website for testing various combinations. It happens when the difference is 8 days, 99 days, and various others. I couldn't pinpoint a specific trigger.
https://www.timeanddate.com/date/durati ... i2=30&s2=0
If this is indeed a bug with Automagic, is there an alternate way of calculating the number of days between two dates I can use in the meantime?
However, if the time is between 12 AM - 1 AM, sometimes the dates do not subtract correctly.
I recreated the bug with a simplified script:
Code: Select all
start = getDate(2018,3,4);
end = getDate(2018,3,12);
days = (end - start)/86400000;
If I use getDate() and manually set the time on my device to 12:59 AM, immediately at 1 AM it shows the correct number of elapsed days. I have this bug on multiple devices: tablets and a phone.
Some dates don't have this bug. For example, using May instead of March: getDate(2018,5,4) and getDate(2018,5,12). Or using 2017 instead of 2018: getDate(2017,3,4) and getDate(2017,3,12).
I used this website for testing various combinations. It happens when the difference is 8 days, 99 days, and various others. I couldn't pinpoint a specific trigger.
https://www.timeanddate.com/date/durati ... i2=30&s2=0
If this is indeed a bug with Automagic, is there an alternate way of calculating the number of days between two dates I can use in the meantime?