Skip to content

v0.19.0

Latest

Choose a tag to compare

@github-actions github-actions released this 02 Nov 07:47
· 175 commits to main since this release
v0.19.0
c37cc33

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 Cron with the built-in Parser uses its name as the H hash key. A job that has both a name and a parser key (WithHashKey) gets new H values, and renaming a job moves it (#471).
  • H/1, H in the day-of-week field, and an H step 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 the Hash option, which FullParser() includes and the default parser of New() does not: use New(WithParser(FullParser())). An unnamed job keeps the parser's WithHashKey; a custom ScheduleParser still needs its own key. ADR-028 records the decision. By @CybotTM (#471).
  • H/1 selects every value like */1. H in the day-of-week field chooses each of the seven days equally often; before, Sunday was chosen twice as often. An H step at or above the size of its range selects one value; before, a step larger than the range could leave the field empty, and Next returned 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, ParseWithHashKey could return the schedule cached for another key. By @CybotTM (#466).
  • doc.go and docs/API_REFERENCE.md describe the H syntax, and new Example functions 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 Next reports that run from any start time before it. 15 2 * * * in Australia/Lord_Howe and 30 0 * * * in America/Santiago had no run on their transition days. Reported by @norman-abramovitz in #444 and #445, fixed by @CybotTM (#449).
  • Next starts 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, LW and nW match the right day in zones that skip the midnight of a month's last day. Before, L in Atlantic/Azores ran on 2024-03-30 instead of 2024-03-31 (#465).
  • Prev returns 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).
  • Next and Prev return the right times in a zone whose UTC offset is not a whole number of minutes, such as a time.FixedZone with seconds (#454).
  • WithMissedPolicy computes catch-up times in the cron location, also when the WithPrev value 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-20000000 took 3.6 s and 2 GiB to parse; it now returns an error at once. All years up to 99999 fit, and 1-2147483647/100000 still parses. Reported by @norman-abramovitz in #472, fixed by @CybotTM (#473).
  • New parse option DowStepToSaturday: a day-of-week N/step runs up to Saturday, as in robfig/cron. RobfigCompat includes it, so 0 0 * * 1/2 runs 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