04-27-2021 09:43
Fitbit Product Experts Alumni are retired members of the Fitbit Product Expert Program. Learn more
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.
Best Answer04-30-2021 06:29
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
04-30-2021 06:29
Can you provide a bit more info? Which device and firmware version, and a small code snippet.
Thanks
Best Answer04-30-2021 07:10 - edited 04-30-2021 07:12
Fitbit Product Experts Alumni are retired members of the Fitbit Product Expert Program. Learn more
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.
Best Answer04-30-2021 07:35
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
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
Best Answer04-30-2021 08:18
Fitbit Product Experts Alumni are retired members of the Fitbit Product Expert Program. Learn more
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.
Best Answer04-30-2021 10:05 - edited 04-30-2021 10:39
Fitbit Product Experts Alumni are retired members of the Fitbit Product Expert Program. Learn more
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.
Best Answer05-05-2021 00:34
Fitbit Product Experts Alumni are retired members of the Fitbit Product Expert Program. Learn more
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.
Best Answer05-05-2021 00:49
Gold Fitbit Product Experts share support knowledge on the forums and advocate for the betterment of Fitbit products and services. Learn more
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.
Best Answer05-05-2021 01:06
Fitbit Product Experts Alumni are retired members of the Fitbit Product Expert Program. Learn more
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.
Best Answer05-07-2021 10:03
Fitbit Product Experts Alumni are retired members of the Fitbit Product Expert Program. Learn more
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.