ev_periodic like functionality for time intervals

Thilo Schulz thilo at tjps.eu
Wed May 20 04:06:01 CEST 2015

Dear list, der Mr. Lehman,

for my program, I need some kind of output variable which shall have two 
states depending on wall clock time:

- 22:00 to 10:00: off
- 10:00 to 22:00 on

and a callback that is to be called upon change of this state.
An ev_periodic watcher seems to be ideal here.
If I understand the documentation correct, a state change would be detected 
if, for instance, PC time jumps from, say
2015-05-19 13:00:00 to 2015-05-19 23:00:00
but not if PC time jumps backwards like
2015-05-19 23:00:00 to 2015-05-18 13:00:00
which is of course undesirable.

I guess in the latter case, I will need to detect a time jump backwards by, 
for instance, comparing the return value of ev_now() with the return value of 
ev_now() from a previous event loop iteration in an ev_check watcher.

Just want to avoid any unpleasant surprises.

Best regards,
Thilo Schulz

More information about the libev mailing list