An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

        

# SwiftCronParser

SwiftCronParser is a Swift Package for parsing cron expressions.

[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2F0xWDG%2FSwiftCronParser%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/0xWDG/SwiftCronParser)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2F0xWDG%2FSwiftCronParser%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/0xWDG/SwiftCronParser)
[![Swift Package Manager](https://img.shields.io/badge/SPM-compatible-brightgreen.svg)](https://swift.org/package-manager)
![License](https://img.shields.io/github/license/0xWDG/SwiftCronParser)

## 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 SwiftCronParser

let 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/).