Update Clock Help

So, widgets with clocks like I have in Widgetsmith work fine. But when I try to make one in Scriptable it takes several minutes to update. What am I doing wrong and why is it different?

Given the following code for a simple clock test, the timer updates (counts) up steadily but the clock takes several minutes to update.

let date = new Date()
let w = new ListWidget()
w.addDate(date).applyTimeStyle()
w.addDate(date).applyTimerStyle()
w.presentSmall()

Is making a simple click in Scriptable not possible?

I think it is because you are building a general widget with a clock, rather than a time widget. Hence it is running to a more constrained refresh cycle.

To build a truly custom time widget, you would need to do it at the app level, or find an existing app that offered you enough parameters for a time widget to meet your needs.

See also:

https://developer.apple.com/documentation/widgetkit/keeping-a-widget-up-to-date

thanks sylumer. So not possible with Scriptable?

Well… it’s kind of possible, but the format of the time has to be in a very specific way (HH:mm:ss or h:mm:ss). Reason is, the method uses the timer style.

Here is a Reddit post explaining

3 Likes

Very nice. I didn’t think that would affect the operation of the underlying widget like that. I guess either i*OS is more flexible around that than I expected, or Simon’s catered for this within the app.

Yeah, it’s more of a workaround, I think keeping a running time is possible but it’s a shame it can’t be formatted differently

1 Like

So, basically by showing the seconds in the applyTimeStyle it should work. But by

You mean the display can’t be formatted or the time format can’t change. I assumed you mean the time format cannot change but can the display/font/size change?

Edit: Looks like font can definitely be changed. I wonder if there’s a way to send the whole thing to a string and sub off the last bit (:ss)?

Exactly.

As for your edit, no. As soon as you turn it to a string, it can no longer be a timer style (at least from the trials I have done before