0.0.6 • Published 1 month ago

@rikal87/is-cron-now v0.0.6

Weekly downloads
-
License
ISC
Repository
github
Last release
1 month ago

is-cron-now

Checks if cron string is active right now or active with custom date

cron support

This is a javascript cron parser so day of the week is 0 - 6 (1 is monday) and month of the year is 0 - 12

this package supports the following cron formats.

* * * * * *
| | | | | |
| | | | | +-- Year              (range: 1900-3000)
| | | | +---- Day of the Week   (range: 0-6, 1 standing for Monday)
| | | +------ Month of the Year (range: 1-12)
| | +-------- Day of the Month  (range: 1-31)
| +---------- Hour              (range: 0-23)
+------------ Minute            (range: 0-59)

basic

* * * * * *

With list

* * * * * 2015,2017,2019

With range

* * * * * 2015-2019

With every

* * * * * 2016/2

With range and list

* 0-6,16-23 * * * *

Example

const { isActive } = require('is-cron-now');

isActive('* 1 */4 11 * 2016-2019', new Date(2018, 11, 16, 1, 0)); // -> true

isActive('24 3 17 11 * 1995', new Date(1995, 11, 17, 3, 24)); // -> true

API

isActive

Takes a cron string and optionally a custom date.

Syntax

isActive('* * * * * *');

isActive('* * * * * 2019', new Date(2019));

Parameters

  • string
    • cron formated string
  • Date?: optionall
    • javascript date

Return value

boolean: cron is active or not

0.0.6

1 month ago

0.0.5

1 month ago

0.0.4

1 month ago

0.0.3

1 month ago