@@ -36,31 +36,12 @@ cron = Cron("*/5 * * * *")
3636prev_time = prev(cron, DateTime(" 2025-01-01T12:03:00" )) # 2025-01-01T12:00:00
3737```
3838
39- Compute next match offset-style (not chrono-style)
40- ``` julia
41- cron = Cron(" */5 * * * *" )
42- next_offset_time = next_offset(cron, DateTime(" 2025-01-01T12:03:00" )) # 2025-01-01T12:08:00
43- ```
44-
4539Generate 4 upcoming triggers strictly after a start time
4640``` julia
4741cron = Cron(" */5 * * * *" )
4842ts = timesteps(cron, DateTime(" 2025-01-01T12:03:00" ), 4 ) # 12:05, 12:10, 12:15, 12:20
4943```
5044
51- Create infinite offset-based iterator from starting point
52- ``` julia
53- cron = Cron(" */5 * * * *" )
54- start = DateTime(" 2025-01-01T12:07:00" )
55- xs = collect(take(gen_times(cron, start), 4 ))
56- # [
57- # DateTime("2025-01-01T12:12:00"),
58- # DateTime("2025-01-01T12:17:00"),
59- # DateTime("2025-01-01T12:22:00"),
60- # DateTime("2025-01-01T12:27:00"),
61- # ]
62- ```
63-
6445Block until the next trigger (uses system clock) ie trigger once
6546``` julia
6647cron = Cron(" */5 * * * *" )
@@ -76,7 +57,7 @@ Trigger every minutes
7657cron = Cron(" */1 * * * *" )
7758@async begin
7859 println(" Waiting… " , now(UTC))
79- wait(c ; tz= UTC)
60+ wait(cron ; tz= UTC)
8061 println(" Triggered at " , now(UTC))
8162end
8263```
@@ -104,15 +85,6 @@ Twice a month: 1st and 15th at 06:30 (Apr/Oct)
10485cron = Cron(" 30 6 1,15 4,10 *" ) # Apr/Oct 1st and 15th at 06:30
10586```
10687
107- Get the next time from an arbitrary point
108- ``` julia
109- using Crontab, Dates
110-
111- c = Cron(" */5 * * * *" )
112-
113- next(c, DateTime(" 2025-01-01T12:03:00" )) # => 2025-01-01T12:05:00
114- ```
115-
11688Example of running tasks asynchronously on cron schedules
11789``` julia
11890using Dates
0 commit comments