-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incomplete reset() when prev() was called before makes next() skip a day #338
Comments
Hi @njoyard! If I removed const parser = require('./');
// Initial `2023-11-21T21:04:39Z` will not be matched, so I had to move the date one hour before
const currentDate = new Date('2023-11-21T20:04:39Z');
const options = {
currentDate,
// You shouldn't need to set this; I just needed that to test out the timezone
tz: 'Europe/Paris'
};
const expr = parser.parseExpression('0 0 22 * * *', options);
console.log(expr.next().toDate()); // 2023-11-21T21:00:00.000Z
console.log(expr.prev().toDate()); // 2023-11-20T21:00:00.000Z
console.log(expr.next().toDate()); // 2023-11-21T21:00:00.000Z The culprit seems to be |
That might be because reset is not passing a timezone into CronDate at Line 804 in fa94e7f
|
When I tested it, I also also briefly tested with passing the tz in reset method - didn't see any difference. Definitely requires a bit more digging. |
I noticed that
next()
skips a day whenprev()
was called before, even ifreset()
has been called.Here is a test case, tested with [email protected]. Local TZ is Europe/Paris (so +1 right now). Not sure if TZ is involved in the issue.
My understanding is that the last return value should be the same as the first. My current workaround is to re-parse the expression every time.
The text was updated successfully, but these errors were encountered: