later icon indicating copy to clipboard operation
later copied to clipboard

Incorrect date

Open alesmenzelsocialbakers opened this issue 8 years ago • 4 comments

later.schedule(...).next(...) gives incorrect next date

Reproduce steps:

var interval = later.parse.text('every 1 mins')
later.schedule(interval).next(1)

Current datetime = Wed Feb 15 2017 11:18:16 GMT+0100 (Central Europe Standard Time) Result: Wed Feb 15 2017 11:18:16 GMT+0100 (Central Europe Standard Time) Expected result: Wed Feb 15 2017 11:19:00 GMT+0100 (Central Europe Standard Time)

alesmenzelsocialbakers avatar Feb 15 '17 10:02 alesmenzelsocialbakers

The start time is considered valid if it meets all of the constraints specified. Since you've only specified that every minute is valid, the current time meets that constraint and is returned. To get your expected result you can either add another constraint for 0 seconds or modify the start time to be on the next minute.

bunkat avatar Feb 15 '17 12:02 bunkat

That does not help. Trying every 0 seconds every 1 minute which results in running 60 times per minute - not what i wanted.

I want to specify interval to run every minute from the closest minute (i.e. first comment).

alesmenzelsocialbakers avatar Feb 15 '17 12:02 alesmenzelsocialbakers

BTW: If I set the interval to 59s, it returns this:

See the +1s and +59s differences, that cant be right.

[ 2017-02-15T18:45:59.078Z,
  2017-02-15T18:46:00.078Z,
  2017-02-15T18:46:59.078Z,
  2017-02-15T18:47:00.078Z,
  2017-02-15T18:47:59.078Z ]

Secondly: Interval 'every 60 s' returns error code 6.

Repro steps:

const later = require('later');
const interval = later.parse.text('every 60 s');
const res = later.schedule(interval).next(5);
console.log(res);

alesmenzelsocialbakers avatar Feb 15 '17 18:02 alesmenzelsocialbakers

Try using this workaround.

mitar avatar Feb 20 '17 09:02 mitar