Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cronskd: parse "-e" value #81

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ $ cronmatch '0 10 * * ? *' 'Oct 10, 2022, 10:10'
'0 10 * * ? *' does not match 'Oct 10, 2022, 10:10'
```

cf. https://github.com/araddon/dateparse
cf. https://pkg.go.dev/github.com/araddon/dateparse#readme-extended-example

# cronviz CLI

Expand Down Expand Up @@ -284,8 +284,20 @@ Mon, 11 Nov 2024 10:00:00 0 10 * * ? *
Mon, 11 Nov 2024 10:05:00 5 8-10 ? * MON-FRI *
Mon, 11 Nov 2024 12:15:00 15 12 * * ? *
Mon, 11 Nov 2024 18:00:00 0 18 ? * MON-FRI *

$ cronskd -s '2024/11/12 10:00' -e 'Nov 13, 2024, 12:00' ~/hoge
Tue, 12 Nov 2024 10:00:00 0 10 * * ? *
Tue, 12 Nov 2024 10:05:00 5 8-10 ? * MON-FRI *
Tue, 12 Nov 2024 12:15:00 15 12 * * ? *
Tue, 12 Nov 2024 18:00:00 0 18 ? * MON-FRI *
Wed, 13 Nov 2024 08:05:00 5 8-10 ? * MON-FRI *
Wed, 13 Nov 2024 09:05:00 5 8-10 ? * MON-FRI *
Wed, 13 Nov 2024 10:00:00 0 10 * * ? *
Wed, 13 Nov 2024 10:05:00 5 8-10 ? * MON-FRI *
```

cf. https://pkg.go.dev/github.com/araddon/dateparse#readme-extended-example

## Related Links

* [Cron expressions reference - Amazon EventBridge](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-cron-expressions.html)
Expand Down
6 changes: 6 additions & 0 deletions cmd/cronskd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ func main() {

if flags.end == "" {
end = time.Date(start.Year(), start.Month(), start.Day(), 23, 59, 50, 0, start.Location())
} else {
end, err = dateparse.ParseAny(flags.end)

if err != nil {
log.Fatal(err)
}
}

nexts := cron.Between(start, end)
Expand Down