Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/1set/cronrange
time range expression in cron style
https://github.com/1set/cronrange
cron cron-definitions cron-expression cron-parser cron-style duration go-package range range-expression time-zone
Last synced: 14 days ago
JSON representation
time range expression in cron style
- Host: GitHub
- URL: https://github.com/1set/cronrange
- Owner: 1set
- License: mit
- Created: 2019-11-10T01:30:45.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-09-04T16:47:05.000Z (about 2 years ago)
- Last Synced: 2024-07-31T20:50:55.872Z (3 months ago)
- Topics: cron, cron-definitions, cron-expression, cron-parser, cron-style, duration, go-package, range, range-expression, time-zone
- Language: Go
- Size: 52.7 KB
- Stars: 18
- Watchers: 2
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - cronrange - Parses Cron-style time range expressions, checks if the given time is within any ranges. (Date and Time / Search and Analytic Databases)
- awesome-go-extra - cronrange - 11-10T01:30:45Z|2022-02-16T22:36:25Z| (Date and Time / Advanced Console UIs)
README
# cronrange
[![GoDoc](https://godoc.org/github.com/1set/cronrange?status.svg)](https://godoc.org/github.com/1set/cronrange)
[![License](https://img.shields.io/github/license/1set/cronrange)](https://github.com/1set/cronrange/blob/master/LICENSE)
[![GitHub Action Workflow](https://github.com/1set/cronrange/workflows/build/badge.svg)](https://github.com/1set/cronrange/actions?workflow=build)
[![Go Report Card](https://goreportcard.com/badge/github.com/1set/cronrange)](https://goreportcard.com/report/github.com/1set/cronrange)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/ef272059b4044252b0097270b48d5703)](https://www.codacy.com/manual/an9an63/cronrange)
[![Codecov](https://codecov.io/gh/1set/cronrange/branch/master/graph/badge.svg)](https://codecov.io/gh/1set/cronrange)cronrange is a Go package for _time range expression_ in _Cron_ style.
In a nutshell, CronRange expression is a combination of Cron expression and time duration to represent periodic time ranges, i.e. **Cron** for Time**Range**. And it made easier to tell if the moment falls within the any time ranges (use [IsWithin()](https://godoc.org/github.com/1set/cronrange#CronRange.IsWithin) method), and what's the next occurrence (use [NextOccurrences()](https://godoc.org/github.com/1set/cronrange#CronRange.NextOccurrences) method).
For example, every New Year's Day in Tokyo can be written as:
```cron
DR=1440; TZ=Asia/Tokyo; 0 0 1 1 *
```It consists of three parts separated by a semicolon:
- `DR=1440` stands for duration in minutes, 60 \* 24 = 1440 min;
- `TZ=Asia/Tokyo` is optional and for time zone using name in [IANA Time Zone database](https://www.iana.org/time-zones);
- `0 0 1 1 *` is a cron expression representing the beginning of the time range.## Installation
To download the package:
```bash
go get -u github.com/1set/cronrange
```## Usage
To import it in your program as:
```go
import "github.com/1set/cronrange"
```Examples can be found in [GoDoc](https://godoc.org/github.com/1set/cronrange#pkg-examples).
## License
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2F1set%2Fcronrange.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2F1set%2Fcronrange?ref=badge_large)