Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/MihaelIsaev/SwifCron
⏱Simple pure swift cron expression parser
https://github.com/MihaelIsaev/SwifCron
Last synced: 3 months ago
JSON representation
⏱Simple pure swift cron expression parser
- Host: GitHub
- URL: https://github.com/MihaelIsaev/SwifCron
- Owner: MihaelIsaev
- License: mit
- Created: 2019-03-06T16:49:55.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-03T11:34:35.000Z (over 1 year ago)
- Last Synced: 2024-05-09T19:14:56.939Z (6 months ago)
- Language: Swift
- Homepage:
- Size: 52.7 KB
- Stars: 29
- Watchers: 2
- Forks: 10
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Mihael Isaev](https://user-images.githubusercontent.com/1272610/53910913-767d1580-406e-11e9-8ed6-f3025f193342.png)](http://mihaelisaev.com)
### Don't forget to support the lib by giving a ⭐️
## How to install
### CocoaPods
SwifCron is available through [CocoaPods](https://cocoapods.org)
To install it, simply add the following line in your Podfile:
```ruby
pod 'SwifCron', '~> 2.0.0'
```### Swift Package Manager
```swift
.package(url: "https://github.com/MihaelIsaev/SwifCron.git", from: "2.0.0")
```
In your target's dependencies add `"SwifCron"` e.g. like this:
```swift
.target(name: "App", dependencies: ["SwifCron"]),
```## Usage
```swift
import SwifCrondo {
let everyMinuteCron = try SwifCron("* * * * *")
let everySecondCron = try SwifCron("* * * * * *")//for getting next date related to current date
let nextMinuteDate = try everyMinuteCron.next()
let nextSecondDate = try everyMinuteCron.next()//for getting next date related to custom date
let nextDate = try cron.next(from: Date())
} catch {
print(error)
}
```## Limitations
This library support both 5 or 6 parts expressions.
With 6 parts format is ```Second``` ```Minute``` ```Hour``` ```Day of month``` ```Month``` ```Day of week```
For creating expressions you can use this [5-parts](https://crontab.guru) or [6-parts (year not supported)](https://www.freeformatter.com/cron-expression-generator-quartz.html) generator
I use [CrontabGuru](https://crontab.guru/) as a reference
So you could parse any expression which consists of digits with `*` `,` `/` and `-` symbols
## Contributing
Please feel free to contribute!
## ToDo
- write more tests
- support literal names of months and days of week in expression
- support non-standard digits like `7` for Sunday in day of week part of expression