FluentScheduler icon indicating copy to clipboard operation
FluentScheduler copied to clipboard

Issue with leap year

Open tuple789 opened this issue 5 years ago • 0 comments

There might be an issue with the leap year, using this code my birthday dates are scheduled one day late. Here for example the ouput says:

Schedule: BirthdaySchedule2 NextRun: Mon 10 08 20 21:22:00 Schedule: BirthdaySchedule1 NextRun: Mon 10 08 20 21:23:00

But the next Schedule should be on the 11 of August or am i missing something?

Reproducible code:

            JobManager.Start();

            Action<Schedule> mySchedule1;
            Action<Schedule> mySchedule2;

            DateTime birthday1 = new DateTime(2019, 8, 11, 21, 14, 00);
            int repeatAmount = 1;
            mySchedule1 = x => x.NonReentrant().WithName("BirthdaySchedule1").ToRunOnceAt(birthday1).AndEvery(repeatAmount).Years().On(birthday1.DayOfYear).At(21, 23);

            mySchedule2 = x => x.NonReentrant().WithName("BirthdaySchedule2").ToRunEvery(1).Years().On(birthday1.DayOfYear).At(21, 22);       

            JobManager.AddJob(new DefaultJob(JobType.Eyes), mySchedule1);
            JobManager.AddJob(new DefaultJob(JobType.Eyes), mySchedule2);

            Console.WriteLine("showing shedules:");
            IEnumerable<Schedule> jobSchedules = JobManager.AllSchedules;
            foreach (Schedule schedule in jobSchedules)
            {
                Console.WriteLine($"Schedule: {schedule.Name} NextRun: {schedule.NextRun}");
            }
            Console.ReadKey();

tuple789 avatar Oct 05 '19 19:10 tuple789