0.0.6 • Published 4 years ago

pcron v0.0.6

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

pcron

NPM version NPM downloads Build status

pcron is a periodical scheduler expression tool inspired by fcron

Example

PT1h 2020 * 21-22 * * *

Like the example above, it means "from 21 through 22 of every month in 2020, the scheduler will be executed every 1 hour".

For more example, see test

Installation

yarn add pcron

or

npm i pcron

Usage

import { parseExpression } from "pcron";
import dayjs from "dayjs";

const timestamp = dayjs("2020-09-23T00:00:00").unix();
// timestamp is a unix timestamp, a current timestamp will be used by default if you omit this parameter
const exp = parseExpression("PT1s 2020 9 23 0 0-1 0-1", timestamp);
const nextDate = exp.next(); // you will get a dayjs object represent 2020-09-23T00:00:01
const nextDate = exp.next(); // you will get a dayjs object represent 2020-09-23T00:01:00
const nextDate = exp.next(); // you will get a dayjs object represent 2020-09-23T00:01:01
const nextDate = exp.next(); // you will get null

Changelog

change log

License

MIT

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago