Repository navigation
Fix release with one feature. Most changes correct Next and Prev around DST transitions and in unusual time zones, and the hash (H) syntax. The minimum Go version stays at 1.26.
Heads-up: three changes can alter results of existing code.
- A named job on a
Cronwith the built-inParseruses its name as theHhash key. A job that has both a name and a parser key (WithHashKey) gets newHvalues, and renaming a job moves it (#471). H/1,Hin the day-of-week field, and anHstep at or above the size of its range select other values than in 0.18.0 (#459).- A year field that selects more than 100,000 years is a parse error (#473).
Hash expressions (H)
- A named job uses its name as the hash key, so
AddFunc("H * * * *", f, WithName("job-a"))works without a parser key, and named jobs with the same spec are spread over the field, as in Jenkins. The parser needs theHashoption, whichFullParser()includes and the default parser ofNew()does not: useNew(WithParser(FullParser())). An unnamed job keeps the parser'sWithHashKey; a customScheduleParserstill needs its own key. ADR-028 records the decision. By @CybotTM (#471). H/1selects every value like*/1.Hin the day-of-week field chooses each of the seven days equally often; before, Sunday was chosen twice as often. AnHstep at or above the size of its range selects one value; before, a step larger than the range could leave the field empty, andNextreturned the zero time. By @CybotTM (#459).- With
WithCache(), the parse cache key holds the spec, every parser setting that changes the result, and the hash key. Before,ParseWithHashKeycould return the schedule cached for another key. By @CybotTM (#466). doc.goanddocs/API_REFERENCE.mddescribe theHsyntax, and newExamplefunctions check every value the documentation quotes (#464).
DST transitions and time zones
- On a DST fall-back day, a spec that runs hourly or more often keeps its rhythm through both copies of the repeated hour, and a spec at fixed times runs each of them once. Before,
0,30 1 * * *in America/New_York ran 01:00 and 01:30 in both EDT and EST. ADR-027 supersedes the fall-back part of ADR-016. Reported by @norman-abramovitz in #446, fixed by @CybotTM (#448). - A job in a DST spring-forward gap runs once on the transition day for gaps of any length and at any hour, and
Nextreports that run from any start time before it.15 2 * * *in Australia/Lord_Howe and30 0 * * *in America/Santiago had no run on their transition days. Reported by @norman-abramovitz in #444 and #445, fixed by @CybotTM (#449). Nextstarts each new year, month and day at its first instant. Before,TZ=America/Asuncion 0 0 25 11 *skipped November 2023, because that date starts at a skipped midnight (#461).L,L-n,#L,LWandnWmatch the right day in zones that skip the midnight of a month's last day. Before,Lin Atlantic/Azores ran on 2024-03-30 instead of 2024-03-31 (#465).Prevreturns at a month that starts in a repeated fall-back period; before, it looped forever there, for example at Asia/Gaza 2004-10-01 (#453).NextandPrevreturn the right times in a zone whose UTC offset is not a whole number of minutes, such as atime.FixedZonewith seconds (#454).WithMissedPolicycomputes catch-up times in the cron location, also when theWithPrevvalue carries another location. A last run time restored in UTC no longer shifts the catch-ups or repeats a day that already ran (#452).
Parser
- A year field selects at most 100,000 years, counted over all items of a list. Before,
1-20000000took 3.6 s and 2 GiB to parse; it now returns an error at once. All years up to 99999 fit, and1-2147483647/100000still parses. Reported by @norman-abramovitz in #472, fixed by @CybotTM (#473). - New parse option
DowStepToSaturday: a day-of-weekN/stepruns up to Saturday, as in robfig/cron.RobfigCompatincludes it, so0 0 * * 1/2runs on Monday, Wednesday and Friday, and no longer also on Sunday as in 0.18.0. Contributed by @mrueg (#443).
Full changelog: v0.18.0...v0.19.0