04-27-2021 09:43
04-27-2021 09:43
It appears that the date doesn't change till 2am.
For most people the date changes at midnight, is there some other reason why the Fitbit OS works to a different standard?
Author | ch, passion for improvement.
04-30-2021 06:29
04-30-2021 06:29
Can you provide a bit more info? Which device and firmware version, and a small code snippet.
Thanks
04-30-2021 07:10 - edited 04-30-2021 07:12
04-30-2021 07:10 - edited 04-30-2021 07:12
Sense - 44.128.4.17
clock.granularity = "seconds";
clock.ontick = (evt) => {
let today = evt.date;
let hours = today.getHours();
let mins = util.zeroPad(today.getMinutes());
let secs = util.zeroPad(today.getSeconds());
if (mins == 0 && secs == 0)
{
var newDay = new Date();
console.log(hours +" " +newDay.toDateString());
}
}
When hours = 2 the date changes.
Author | ch, passion for improvement.
04-30-2021 07:35
04-30-2021 07:35
Yeah, so in Javascript the Date object is UTC.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
If you want the clock time, you should already have it in evt.date
04-30-2021 08:18
04-30-2021 08:18
Unfortunately its in the setInterval so the evt.date is not available as it won't have been updated.
What do you recommend as an alternative?.
Author | ch, passion for improvement.
04-30-2021 10:05 - edited 04-30-2021 10:39
04-30-2021 10:05 - edited 04-30-2021 10:39
Just did a test
let today = evt.date;
Console.log(today.toTimeString());
let myDay = new Date();
Console.log(myDay .toTimeString());
They print the same time. Why, if one is UTC and the other local.?
The .getTimezoneOffset() are also the same.
Author | ch, passion for improvement.
05-05-2021 00:34
05-05-2021 00:34
What it looks like is evt.date returns local date and hours and minutes, but new Date() returns UTC date and local hours and minutes.
Is that possible?
Author | ch, passion for improvement.
05-05-2021 00:49
05-05-2021 00:49
I don't think that `new Date()` has a time zone (except inasmuch as it's the number of milliseconds since 1 January 1970 UTC). It depends how you use it.
05-05-2021 01:06
05-05-2021 01:06
True, then it must be a bug with .getDate() [not sure now that evt.date does actually return local date, as opposed to utc date].
Odd that it seems ok in the test in the OS simulator.
Will investigate further in real conditions on a watch.
Author | ch, passion for improvement.
05-07-2021 10:03
05-07-2021 10:03
It seems toDateString returns a UTC date and toString local time, both using the same date field !!!
Its the same with evt.date and new Date() in the simulator.
Author | ch, passion for improvement.