Swiftpack.co - MihaelIsaev/SwifCron as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by MihaelIsaev.
MihaelIsaev/SwifCron 2.0.0
⏱Simple pure swift cron expression parser
⭐️ 28
🕓 2 years ago
.package(url: "https://github.com/MihaelIsaev/SwifCron.git", from: "2.0.0")

Mihael Isaev

MIT License Swift 4.2 Cocoapod Github Actions Swift.Stream

Don't forget to support the lib by giving a ⭐️

How to install


SwifCron is available through CocoaPods

To install it, simply add the following line in your Podfile:

pod 'SwifCron', '~> 2.0.0'

Swift Package Manager

.package(url: "https://github.com/MihaelIsaev/SwifCron.git", from: "2.0.0")

In your target's dependencies add "SwifCron" e.g. like this:

.target(name: "App", dependencies: ["SwifCron"]),


import SwifCron

do {
    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 {


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 or 6-parts (year not supported) generator

I use CrontabGuru as a reference

So you could parse any expression which consists of digits with * , / and - symbols


Please feel free to contribute!


  • 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


Stars: 28
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

🕙 Add possibility to specify seconds
2 years ago

Now cron expression optionally could be written with seconds!

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics