Jump to content
jdpinto

Time remaining on "delay"

Recommended Posts

I apologize if this has already been asked. I've searched and haven't been able to find an answer to this. Is there a way to get the remaining time on a "delay"? For a timer workflow, I'd like to be able to check how much time is left instead of simply waiting for a notification once the delay has ended.

Share this post


Link to post
On 3/25/2020 at 7:37 PM, jdpinto said:

For a timer workflow, I'd like to be able to check how much time is left instead of simply waiting for a notification once the delay has ended.

 

You don’t want to use a delay for a timer. I don’t know how Alfred implements it, but since it’s meant for a few seconds at a time, it’s likely it tells the Workflow to wait the input seconds.

 

The trouble with that approach is that it’s not precise. As your OS decides which tasks get which cycles, the timer may not run in real time (e.g. if your machine becomes under heavy load and the timer process freezes, when it gets running again it will continue where it stopped). That’s not problematic if you’re waiting a few seconds, but it’s no good when you need a modicum of precision ove several minutes or hours.

 

The correct technique is to save the time at which the timer started and periodically compare it to the current time. That’s how time tracking apps keep counting even if the machine enters sleep mode. Incidentally, I’ve found out about all this when building SandwichTimer.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...