Skip to content

Commit 91cc3b6

Browse files
committed
fix: doc comments
1 parent b9b7a5a commit 91cc3b6

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

coderd/crontab/crontab.go

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// package crontab provides utilities for parsing and deserializing
2+
// cron-style expressions.
13
package crontab
24

35
import (
@@ -7,11 +9,13 @@ import (
79
"golang.org/x/xerrors"
810
)
911

12+
// For the purposes of this library, we only need minute, hour, and
13+
//day-of-week.
1014
const parserFormat = cron.Minute | cron.Hour | cron.Dow
1115

1216
var defaultParser = cron.NewParser(parserFormat)
1317

14-
// CronSchedule represents a weekly cron schedule serializable to and from a string.
18+
// Parse parses a WeeklySchedule from spec.
1519
//
1620
// Example Usage:
1721
// local_sched, _ := cron.Parse("59 23 *")
@@ -20,24 +24,6 @@ var defaultParser = cron.NewParser(parserFormat)
2024
// us_sched, _ := cron.Parse("CRON_TZ=US/Central 30 9 1-5")
2125
// fmt.Println(sched.Next(time.Now()).Format(time.RFC3339))
2226
// // Output: 2022-04-04T14:30:00Z
23-
24-
// WeeklySchedule is a thin wrapper for cron.SpecSchedule that implements Stringer.
25-
type WeeklySchedule struct {
26-
sched *cron.SpecSchedule
27-
// XXX: there isn't any nice way for robfig/cron to serialize
28-
spec string
29-
}
30-
31-
// String serializes the schedule to its original human-friendly format.
32-
func (s WeeklySchedule) String() string {
33-
return s.spec
34-
}
35-
36-
// Next returns the next time in the schedule relative to t.
37-
func (s WeeklySchedule) Next(t time.Time) time.Time {
38-
return s.sched.Next(t)
39-
}
40-
4127
func Parse(spec string) (*WeeklySchedule, error) {
4228
specSched, err := defaultParser.Parse(spec)
4329
if err != nil {
@@ -55,3 +41,21 @@ func Parse(spec string) (*WeeklySchedule, error) {
5541
}
5642
return cronSched, nil
5743
}
44+
45+
// WeeklySchedule represents a weekly cron schedule.
46+
// It's essentially a thin wrapper for robfig/cron/v3 that implements Stringer.
47+
type WeeklySchedule struct {
48+
sched *cron.SpecSchedule
49+
// XXX: there isn't any nice way for robfig/cron to serialize
50+
spec string
51+
}
52+
53+
// String serializes the schedule to its original human-friendly format.
54+
func (s WeeklySchedule) String() string {
55+
return s.spec
56+
}
57+
58+
// Next returns the next time in the schedule relative to t.
59+
func (s WeeklySchedule) Next(t time.Time) time.Time {
60+
return s.sched.Next(t)
61+
}

0 commit comments

Comments
 (0)