[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Timers for weekly events
From: |
Christopher Howard |
Subject: |
Re: Timers for weekly events |
Date: |
Wed, 24 Jul 2024 09:35:22 -0800 |
So, let's say you want to have a run-at-time call in your init.el, which starts
a timer that will execute once per week, say Tuesday at 4am. How exactly do you
go about this?
One option would be you could pass a time of day to run-at-time. However, then
the function you call needs to implement two things: (1) it needs to first
check if it is on the right day of the week; (2) due to the design of
run-at-time, it will need to check if the time is *actually* the correct time
of day, since when passing a time-of-day to run-at-time, run-at-time will go
ahead and call the function if the specified time of day has already occured
anytime in the past day. (I once mistakenly reported this as a bug.)
Alternatively, we can pass in a relative time (number of seconds) until the
next occurrence of Tuesday 4am. But how does the user calculate that value,
without having to supply his own additional function that somehow works out the
logic and math? So far as I know, there isn't any built in elisp function that
makes such a calculation simple for the user.
I chose the second approach, as it does not require the callback to have any
knowledge of times and dates and such. And then I wrote my own function, as
documented in my post
<http://gem.librehacker.com/gemlog/starlog/20240723-0.gmi>. But it seems like
this, or some other simple solution, should be readily available to all users
of the timer library.
--
Christopher Howard