breejs / later

*Maintained fork of Later.* A javascript library for defining recurring schedules and calculating future (or past) occurrences for them. Includes support for using English phrases and Cron schedules. Works in Node and in the browser.
https://breejs.github.io/later/
MIT License
134 stars 13 forks source link

Every 5th of September and December #5

Closed ranouf closed 3 years ago

ranouf commented 3 years ago

Hi,

When I execute this code: var scheduler = later.parse.recur().on(12).month() .and().on(9).month() .and().on(5).dayOfMonth();

  later.date.localTime();
  var results = later.schedule(scheduler).next(3);

I was thinking to get:

But I receive:

How to get the expected result? Thanks

ranouf commented 3 years ago

The solution was to remove the and()

niftylettuce commented 3 years ago

Ah nice!

You could also do two cron jobs that reference the same path, and just duplicate the job definition object with unique name values, e.g. { path: '...', name: 'september', cron: '0 0 5 9 *' } and { path: '...', name: 'december', cron: '0 0 5 12 *' } (see https://crontab.guru/#0_0_5_9_*).

niftylettuce commented 3 years ago

(if you're using bree that is)