Skip to content

node-cron's month does not follow normal cron spec #475

@mogzol

Description

@mogzol

node-cron's month is 0-based, while cron months are regularly 1-based. See the cron manpage: http://man7.org/linux/man-pages/man5/crontab.5.html:

field          allowed values
-----          --------------
minute         0-59
hour           0-23
day of month   1-31
month          1-12 (or names, see below)
day of week    0-7 (0 or 7 is Sunday, or use names)

So specifying a month of 4 should be April, but with node-cron, it is May: https://stackblitz.com/edit/js-7fmtr2

I don't see why node-cron would use 0-based values for the month. It is confusing for users used to other cron tools, especially when the readme recommends tools such as crontab.guru, which will tell users the wrong month: https://crontab.guru/#0_0_1_4_*

The only place in the readme that mentions this is the section that outlines cron ranges, and it fails to point out that this deviates from normal cron behaviour. It should be made more clear that node-cron's months are non-standard, or node-cron should be updated to match regular cron behaviour (though that would cause a BC break).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions