Skip to content

Commit 1cacb45

Browse files
committed
Fix README mentioned of nth weekday
Add example of nth weekday
1 parent bccb95d commit 1cacb45

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ This package implements the specification found in [Wikipedia](https://en.wikipe
3232
* `,` can be used to list values (e.g. `1,2,3` means values 1, 2 and 3).
3333
* `/` can be used to specify an interval (e.g. `1/5` means values 1, 6, 11, 16, etc...).
3434
* `L` when used in the month field specifies the last day of the month and Saturday when used in the week day field. Using a digit before the character in the week day field specifies the nth last week day of the month (e.g. `1L` for the last Monday of the month). An offset can also be used for the month field (e.g. `L-2` for the second last day of the month).
35-
* `#` can be used to specify the nth week day of the month (e.g. `6#3` for the third (`3`) Friday (`6`) of the month).
35+
* `#` can be used to specify the nth week day of the month (e.g. `6#3` for the third (`3`) Saturday (`6`) of the month).

examples_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,20 @@ func ExampleSchedule_Upcoming_everySecondToLastDayOfEveryTwoMonths() {
8282
// 2024-01-30 00:00:00 +0000 UTC
8383
// 2024-03-30 00:00:00 +0000 UTC
8484
}
85+
86+
func ExampleSchedule_Upcoming_everyThirdThursdayOfEachMonth() {
87+
schedule := gocron.MustParse("0 0 0 ? * 4#3")
88+
89+
iter := schedule.Upcoming(time.Date(2023, time.June, 4, 0, 0, 0, 0, time.UTC))
90+
for i := 0; i < 5 && iter.HasNext(); i++ {
91+
next := iter.Next()
92+
fmt.Println(next)
93+
}
94+
95+
// Output:
96+
// 2023-06-15 00:00:00 +0000 UTC
97+
// 2023-07-20 00:00:00 +0000 UTC
98+
// 2023-08-17 00:00:00 +0000 UTC
99+
// 2023-09-21 00:00:00 +0000 UTC
100+
// 2023-10-19 00:00:00 +0000 UTC
101+
}

0 commit comments

Comments
 (0)