cron

package
v0.0.0-...-9489f8d Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

*

  • @Author: kwens
  • @Date: 2022-10-09 17:39:09
  • @Description:

*

  • @Author: kwens
  • @Date: 2022-09-02 09:42:47
  • @Description:

*

  • @Author: kwens
  • @Date: 2022-10-10 09:35:03
  • @Description:

Index

Constants

View Source
const (
	SPEC_ZERO_TIME             = "0 0 0 * * *"  // 每天凌晨0点
	SPEC_ZERO_AFTER_15MIN_TIME = "0 15 0 * * *" // 每天凌晨0点15分
)

Variables

View Source
var (
	Cron *cron
)
View Source
var CronPosition = struct {
	Sec  Position
	Min  Position
	Hour Position
	Day  Position
	Mon  Position
	Week Position
	Year Position
}{
	cronPositionSec,
	cronPositionMin,
	cronPositionHour,
	cronPositionDay,
	cronPositionMon,
	cronPositionWeek,
	cronPositionYear,
}

Functions

func New

func New() *cron

func Start

func Start()

Types

type CronExpr

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

func NewCronExpr

func NewCronExpr() *CronExpr

func (*CronExpr) Gen

func (ce *CronExpr) Gen() (string, error)

Gen 生成表达式 如果某个位置的表达式条件不适用规则,则默认返回“*”,比如在min位置适用WithNoDesignate 如果传入的表达式条件为范围值,当不符合范围要求时,直接报错

func (*CronExpr) SetCondition

func (ce *CronExpr) SetCondition(opts ...CronExprOption) error

SetCondition 设置表达式条件,同个位置的条件只会生效最后一个

type CronExprOption

type CronExprOption interface {
	// contains filtered or unexported methods
}

func With24TimeStr

func With24TimeStr(timestr string) []CronExprOption

With24TimeStr 24小时制的时间设置,eg: 12:20:00

func WithCustom

func WithCustom(custom []int, position Position) CronExprOption

WithCustom

func WithEvery

func WithEvery(position Position) CronExprOption

func WithInterval

func WithInterval(begin, sep int, position Position) CronExprOption

func WithLastDay

func WithLastDay() CronExprOption

WithLastDay 本月最后一天

func WithLastWeek

func WithLastWeek(weekDay int) CronExprOption

WithLastWeek 本月最后一个星期几 @param.weekDay: 1-7

func WithNearWorkDay

func WithNearWorkDay(day int) CronExprOption

WithNearWorkDay 每月几号最近的工作日 @param.day: 1-31

func WithNoDesignate

func WithNoDesignate(position Position) CronExprOption

WithNoDesignate 不指定,只有日/星期有, 传入其他位置则返回nil

func WithRange

func WithRange(begin, end int, position Position) CronExprOption

type Position

type Position int

type PositionLimit

type PositionLimit []int

Jump to

Keyboard shortcuts

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