datetime

package
v0.0.0-...-50176c9 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2020 License: Apache-2.0, Apache-2.0 Imports: 8 Imported by: 0

README

Go-Crontab˵��

Go-Crontab ʵ����Linux�ϵ�crontab�����Ĺ��ܡ���ʽ���£� s m h d M w �ֱ������룬�֣�ʱ���죬�£����ڡ�֧���﷨��

  • * * * * * * <=> */1 * * * * * ÿ��
  • */n * * * * * ÿn��(���Ƶ��� - * */n * * * * ÿn���� * * */n * * * ÿnСʱ * * * */n * * ÿn�� - * * * * */n * ÿn�£�����30���ƣ� * */n * * * * ÿn����)
  • m-n * * * * * ÿ����m-n��
  • a,b,c[,...] * * * * * ÿ���ӵ�a,b,c[,...]��
  • a,b,c[,...],m-n * * * * * ÿ���ӵ�a,b,c[,...]��m-n��

ע�⣺

  1. ÿn��(�֣�ʱ���죬�£�����)�ı�ʾ������֧��������ʾ������ֻ������һ������Ϊ*/n����ʽ������ */n */m * * * *�ı�ʾ������������Ȼ���ᱨ�������Ƕ��ڳ����Ľ�����ʽ��˵���ò�������Ԥ�ڵ�Ч�����������ַ�ʽ�Dz������ġ�
  2. �룬�֣�ʱ���죬�£����ڵ���Ч��ֵ�ֱ��ǣ� 0-59, 0-59, 0-24, 1-31, 1-12, 0-6�����ڵ�0���������գ������ֱ���Ӧ������һ����������

Documentation

Index

Constants

View Source
const (
	// DateFormat yyyy-MM-dd
	DateFormat = "2006-01-02"

	// DateTimeFormat yyyy-MM-dd HH:mm:ss
	DateTimeFormat = "2006-01-02 15:04:05"
)
View Source
const (
	FORMAT_ERROR = "format error"
)

Variables

This section is empty.

Functions

func ParseDate

func ParseDate(val string) time.Time

ParseDate yyyy-MM-dd

func ParseDateTime

func ParseDateTime(val string) time.Time

ParseDateTime yyyy-MM-dd HH:mm:ss

Types

type Crontab

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

func NewCrontab

func NewCrontab(args string, handlers ...Handler) (Crontab, error)

create crontab jobs from args

func (*Crontab) Start

func (c *Crontab) Start()

start the crontab jobs

func (*Crontab) Stop

func (c *Crontab) Stop()

stop the crontab jobs

type Handler

type Handler interface{}

type Timestamp

type Timestamp time.Time

Timestamp 解析json成毫秒

func NewTimestamp

func NewTimestamp() Timestamp

NewTimestamp return Local Time

func (Timestamp) MarshalJSON

func (t Timestamp) MarshalJSON() ([]byte, error)

func (Timestamp) String

func (t Timestamp) String() string

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(b []byte) error

UnmarshalJSON 将时间戳字符串转换为时间

Jump to

Keyboard shortcuts

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