internal

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFileNotFound      = fmt.Errorf("file not found")
	ErrInvalidCronFormat = fmt.Errorf("invalid cron format")
)

Functions

func InitTaskFile added in v0.1.1

func InitTaskFile(taskFile string) error

func Match

func Match(schedule cron.Schedule, tt time.Time) bool

func ParseRecurrence

func ParseRecurrence(recurrence string) (cron.Schedule, error)

func SameDay

func SameDay(t1, t2 time.Time) bool

func SaveTasks

func SaveTasks(taskFile string, tasks []Task) error

Types

type Task

type Task struct {
	Title       string `json:"title"`
	Recurrence  string `json:"recurrence"`
	Description string `json:"description"`
}

Task represents a task Recurrence is a cron format but only supports Dom, Month, and Dow Dom: Day of the month: 1-31, "* / , - ?" Month: Month of the year: 1-12 or JAN-DEC, "* / , -" Dow: Day of the week: 0-6 or SUN-SAT, "* / , - ?"

func LoadTasks

func LoadTasks(taskFile string) ([]Task, error)

func (*Task) Match

func (t *Task) Match(tt time.Time) (bool, error)

Match returns true if the task is in the given time (only check the day)

func (*Task) Next

func (t *Task) Next(tt time.Time) (time.Time, error)

Next returns the next time of the task

func (*Task) Verify

func (t *Task) Verify() error

Verify returns an error if the task is invalid

Jump to

Keyboard shortcuts

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