https://github.com/0xwdg/swiftcronparser
SwiftCronParser is a Swift Package for parsing cron time definitions.
https://github.com/0xwdg/swiftcronparser
0xwdg cron cronjob cronparser crontab swift swiftlang
Last synced: 3 months ago
JSON representation
SwiftCronParser is a Swift Package for parsing cron time definitions.
- Host: GitHub
- URL: https://github.com/0xwdg/swiftcronparser
- Owner: 0xWDG
- License: mit
- Created: 2025-01-02T18:29:47.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2025-01-20T19:13:27.000Z (5 months ago)
- Last Synced: 2025-03-13T16:55:46.273Z (3 months ago)
- Topics: 0xwdg, cron, cronjob, cronparser, crontab, swift, swiftlang
- Language: Swift
- Homepage: https://0xwdg.github.io/SwiftCronParser/
- Size: 326 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# SwiftCronParser
SwiftCronParser is a Swift Package for parsing cron expressions.
[](https://swiftpackageindex.com/0xWDG/SwiftCronParser)
[](https://swiftpackageindex.com/0xWDG/SwiftCronParser)
[](https://swift.org/package-manager)
## Requirements
- Swift 5.9+ (Xcode 15+)
- iOS 13+, macOS 10.15+## Installation (Pakage.swift)
```swift
dependencies: [
.package(url: "https://github.com/0xWDG/SwiftCronParser.git", branch: "main"),
],
targets: [
.target(name: "MyTarget", dependencies: [
.product(name: "SwiftCronParser", package: "SwiftCronParser"),
]),
]
```## Installation (Xcode)
1. In Xcode, open your project and navigate to **File** โ **Swift Packages** โ **Add Package Dependency...**
2. Paste the repository URL (`https://github.com/0xWDG/SwiftCronParser`) and click **Next**.
3. Click **Finish**.## Usage
```swift
import SwiftUI
import SwiftCronParserlet cronParser = SwiftCronParser(input: "0 0 * * *")
let cronTime = cronParser.parse()if let error = cronTime.error {
print("Error: \(error)")
} else {
print("Cron string: \(cronTime)") // 0 0 0,1,2,3,4,5,6 1,2,3,4,5,6,7,8,9,10,11,12 0,1,2,3,4,5,6
// Or using cronTime.minute, cronTime.hour, cronTime.dayOfMonth, cronTime.month, cronTime.dayOfWeek
}
```## Blogpos
This [Blog post](http://wesleydegroot.nl/blog/Building-iWebTools#:~:text=Tool:%20crontab%20converter) explains how I used this library in my app [iWebTools](https://wesleydegroot.nl/apps/iWebTools).
## Contact
๐ฆ [@0xWDG](https://bsky.app/profile/0xWDG.bsky.social)
๐ [mastodon.social/@0xWDG](https://mastodon.social/@0xWDG)
๐ฆ [@0xWDG](https://x.com/0xWDG)
๐งต [@0xWDG](https://www.threads.net/@0xWDG)
๐ [wesleydegroot.nl](https://wesleydegroot.nl)
๐ค [Discord](https://discordapp.com/users/918438083861573692)Interested learning more about Swift? [Check out my blog](https://wesleydegroot.nl/blog/).