diff --git a/SW.Scheduler/QuartzSchedulerViewerCommand.cs b/SW.Scheduler/QuartzSchedulerViewerCommand.cs index 086256c..69c98ac 100644 --- a/SW.Scheduler/QuartzSchedulerViewerCommand.cs +++ b/SW.Scheduler/QuartzSchedulerViewerCommand.cs @@ -106,7 +106,7 @@ public async Task RescheduleAsync(string group, string name, string newCronExpre var newTrigger = TriggerBuilder.Create() .WithIdentity(existing.Key) .ForJob(jobKey) - .WithCronSchedule(newCronExpression) + .WithCronSchedule(newCronExpression, b => b.InTimeZone(TimeZoneInfo.Utc)) .Build(); await scheduler.RescheduleJob(existing.Key, newTrigger, ct); diff --git a/SW.Scheduler/ScheduleRepository.cs b/SW.Scheduler/ScheduleRepository.cs index 6b7c81f..3cf7610 100644 --- a/SW.Scheduler/ScheduleRepository.cs +++ b/SW.Scheduler/ScheduleRepository.cs @@ -91,7 +91,7 @@ public static ITrigger RebuildCronTrigger(ITrigger existing, string newCronExpre => TriggerBuilder.Create() .WithIdentity(existing.Key) .ForJob(existing.JobKey) - .WithCronSchedule(newCronExpression, b => b.ApplyMisfire(misfire)) + .WithCronSchedule(newCronExpression, b => b.ApplyMisfire(misfire).InTimeZone(TimeZoneInfo.Utc)) .UsingJobData(existing.JobDataMap) .Build(); } @@ -166,7 +166,7 @@ public async Task Schedule(TParam param, string cronExpressi var trigger = TriggerBuilder.Create() .WithIdentity(triggerKey) .ForJob(jobKey) - .WithCronSchedule(cronExpression, b => b.ApplyMisfire(config.MisfireInstructions)) + .WithCronSchedule(cronExpression, b => b.ApplyMisfire(config.MisfireInstructions).InTimeZone(TimeZoneInfo.Utc)) .Build(); await scheduler.ScheduleJob(job, trigger); @@ -192,7 +192,7 @@ public async Task Schedule(string cronExpression, ScheduleConfig? co var newTrigger = TriggerBuilder.Create() .WithIdentity(triggerKeyObj) .ForJob(jobKey) - .WithCronSchedule(cronExpression, b => b.ApplyMisfire(config.MisfireInstructions)) + .WithCronSchedule(cronExpression, b => b.ApplyMisfire(config.MisfireInstructions).InTimeZone(TimeZoneInfo.Utc)) .Build(); // If the config (concurrency / recovery) has changed, update the stored durable job too. @@ -417,7 +417,7 @@ public async Task ScheduleIfNotExists(TParam param, st var trigger = TriggerBuilder.Create() .WithIdentity(triggerKey) .ForJob(jobKey) - .WithCronSchedule(cronExpression, b => b.ApplyMisfire(config.MisfireInstructions)) + .WithCronSchedule(cronExpression, b => b.ApplyMisfire(config.MisfireInstructions).InTimeZone(TimeZoneInfo.Utc)) .Build(); await scheduler.ScheduleJob(job, trigger); diff --git a/SW.Scheduler/SchedulerPreparation.cs b/SW.Scheduler/SchedulerPreparation.cs index ed9b933..c2b7f4d 100644 --- a/SW.Scheduler/SchedulerPreparation.cs +++ b/SW.Scheduler/SchedulerPreparation.cs @@ -96,7 +96,7 @@ private async Task RegisterJob(IScheduler scheduler, ScheduledJobDefinition jobD .WithIdentity(triggerKey) .ForJob(jobKey) .WithCronSchedule(scheduleAttr.CronExpression, - b => b.ApplyMisfire(config.MisfireInstructions)) + b => b.ApplyMisfire(config.MisfireInstructions).InTimeZone(TimeZoneInfo.Utc)) .WithDescription(scheduleAttr.Description) .Build(); @@ -145,7 +145,7 @@ private async Task RegisterCleanupJob(IScheduler scheduler, SchedulerOptions opt .WithIdentity(triggerKey) .ForJob(jobKey) .WithCronSchedule(options.CleanupCronExpression, - b => b.WithMisfireHandlingInstructionDoNothing()) + b => b.WithMisfireHandlingInstructionDoNothing().InTimeZone(TimeZoneInfo.Utc)) .WithDescription($"Deletes JobExecution records older than {options.RetentionDays} days.") .Build();