cadence

package module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2025 License: MIT Imports: 6 Imported by: 0

README

⏰ Cadence

This package is a simple interface in to calculating the next occurence of an event based on cron syntax. It also supports a more human-readable syntax to make, all behind a single interface.

import "github.com/bradhe/cadence"

Example

package main

import (
    "fmt"

    "github.com/bradhe/cadence"
)

func main() {
    // Supports cron syntax with seconds
    t, _ := cadence.Next("*/5 * * * * *", time.Now()))
    fmt.Printf("Next run: %v\n", t)

    // Special cases some human readable syntax, too!
    t, _ = cadence.Next("every hour", time.Now()))
    fmt.Printf("Next run: %v\n", t)
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPattern = errors.New("cadence: invalid pattern")
	ErrNotImplemented = errors.New("cadence: not implemented")
	ErrEOF            = errors.New("cadence: eof")
)

Functions

func IsValid

func IsValid(pattern string) bool

IsValid will tell you if the pattern can be parsed by cadence.

func Next

func Next(pattern string, last time.Time) (time.Time, error)

Next uses the supplied pattern to determine when the next occurance of the event should be.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址