-
Notifications
You must be signed in to change notification settings - Fork 131
Open
Description
Hello there!
This issue was initially spotted using Hangfire jobs scheduler, but I managed to investigate it to the following point:
So, imagine we have a cron 0 0 2 * * 0 (run at 2:00 each Sunday) and a specific time zone W. Europe Standard Time (supports DST, UTC+1 when non-DST, UTC+2 when DST). And Sunday 27th of October is the day when we move from DST to non-DST which leads to time 02:00 in this timezone happen twice (at 00:00 UTC and 01:00 UTC).
We request next occurrence exactly at 00:30 UTC and expect it to be 01:00 UTC time, but it is actually skipped.
And here is a code to reproduce it:
using Cronos;
using TimeZoneConverter;
var cron = CronExpression.Parse("0 0 2 * * 0", CronFormat.Standard | CronFormat.IncludeSeconds);
var requestedAt = new DateTime(2024, 10, 27, 0, 30, 0, DateTimeKind.Utc);
var nextOccurrence = cron.GetNextOccurrence(requestedAt, TZConvert.GetTimeZoneInfo("W. Europe Standard Time"), inclusive: false);
Console.WriteLine(nextOccurrence?.ToString("o"));
The code output is 2024-11-03T01:00:00.0000000Z - next week. And I would expect it to be 2024-10-27T01:00:00.0000000Z
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
