02-06-2024 13:58
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

02-06-2024 13:58
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I have a bit of a strange issue in the clockface I am trying to build. I have been following the sdk-moment example repo on Github, on there they have a `simpleClock` component, which has a clock granularity set to minutes, and then an `simpleActivity` component with a clock granularity of seconds. Technically speaking I want to do that in the opposite way and have the clock every second but activity data every minute so it doesn't hammer battery usage too much.
The issue I find (and this happens with the example code too) is that the granularity is global depending on the last granularity to be set. Is there a way to have these run independently? or would I perhaps have to have one listener that is called every second globally, that then calls other things (like activity data) when the seconds value is 00? instead of linking them to "ticks" in their own right
Answered! Go to the Best Answer.

Accepted Solutions
02-06-2024 14:10
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


02-06-2024 14:10
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
You're on the right track. granularity is a property of the clock object, of which there is only one instance.
Testing for seconds==0 is slightly risky because the clockface may not be active at exactly that moment (and I've seen it skip seconds too). Keeping track of the last hour and minute values, and then seeing if there's been a change every second, works. Or you could get fancier and keep track of a Date value that indicates when you next want to update activity data.
Gondwana Software
02-06-2024 14:10
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


02-06-2024 14:10
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
You're on the right track. granularity is a property of the clock object, of which there is only one instance.
Testing for seconds==0 is slightly risky because the clockface may not be active at exactly that moment (and I've seen it skip seconds too). Keeping track of the last hour and minute values, and then seeing if there's been a change every second, works. Or you could get fancier and keep track of a Date value that indicates when you next want to update activity data.
Gondwana Software
02-06-2024 17:14 - edited 02-06-2024 17:26
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


02-06-2024 17:14 - edited 02-06-2024 17:26
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Hi @stefanwright88 - the issue as mentioned by @Gondwana is the clock stops when the display is off.
However using a setInterval will activate even if the display is off.
Using a combination of a seconds granularity and a 60 second interval (in ms) will give you roughly what you need. The interval can drift but should be good enough to trigger about once a minute.
Author | ch, passion for improvement.
02-11-2024 02:50
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

