schedule

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package schedule 算定时的下次时间:每天、每隔几天、每周、每月、cron 表达式与一次(追剧的主动搜索与定时 AI 任务共用)。 时间按给定的时区(通常是进程的时区)算墙上时间:夏令时切换的那天照样是那个钟点。

Index

Constants

View Source
const (
	Daily     = "daily"
	EveryDays = "every_days"
	Weekly    = "weekly"
	Monthly   = "monthly"
	Once      = "once"
	// Cron 按 cron 表达式(见 cron.go)
	Cron = "cron"
)

定时方式。

View Source
const MaxCronExprs = 10

MaxCronExprs 是一个定时最多几条 cron 表达式。

View Source
const MaxEvery = 30

MaxEvery 是「每隔几天」最多几天。

Variables

View Source
var ErrInvalid = errors.New("定时不对")

ErrInvalid 是定时写得不对。

Functions

func Clock

func Clock(at string) (hour, minute int, err error)

Clock 解析 HH:MM。

func Next

func Next(s Spec, after time.Time, loc *time.Location) (time.Time, bool)

Next 是 after 以后(不含 after)第一个到点的时间;定时不对或一次的时间已经过了时第二个返回值为 false。

Types

type CronSet

type CronSet struct {
	// contains filtered or unexported fields
}

CronSet 是一个定时里的几条 cron 表达式。

func ParseCron

func ParseCron(src string) (CronSet, error)

ParseCron 解析一条或几条(分号或换行分开)cron 表达式。

func (CronSet) Next

func (c CronSet) Next(after time.Time, loc *time.Location) (time.Time, bool)

Next 是 after 以后(不含)几条表达式里最早到点的时间。

func (CronSet) String

func (c CronSet) String() string

String 是规整后的写法:每条的几段用一个空格分开,几条之间用「; 」。

type Spec

type Spec struct {
	Kind string
	// At 是钟点(HH:MM,24 小时制)
	At string
	// Every 是每隔几天(EveryDays,1–MaxEvery)
	Every int
	// Days 是每周的星期几(Weekly,0–6,0 是星期日)或每月的几号(Monthly,1–31;那个月没有这一天时按月末)
	Days []int
	// Anchor 是每隔几天的起点(只看日期,通常是建立的那天)
	Anchor time.Time
	// When 是一次的时间(Once)
	When time.Time
	// Expr 是 cron 表达式(Cron:一条或几条,分号或换行分开)
	Expr string
}

Spec 是一个定时。

func (Spec) Validate

func (s Spec) Validate() error

Validate 检查定时写得对不对。

Jump to

Keyboard shortcuts

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