Fitbit Product Experts Alumni are retired members of the Fitbit Product Expert Program. Learn more
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 Answer
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.
Fitbit Product Experts Alumni are retired members of the Fitbit Product Expert Program. Learn more
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 Answer
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.
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 Answer
Fitbit Product Experts Alumni are retired members of the Fitbit Product Expert Program. Learn more
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 Answer
Fitbit Product Experts Alumni are retired members of the Fitbit Product Expert Program. Learn more
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 Answer
Fitbit Product Experts Alumni are retired members of the Fitbit Product Expert Program. Learn more
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 AnswerI 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 Answer
Fitbit Product Experts Alumni are retired members of the Fitbit Product Expert Program. Learn more
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 Answer
Fitbit Product Experts Alumni are retired members of the Fitbit Product Expert Program. Learn more
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.