Hi,
I am using Hangfire to schedule a one time method to be called and executed at a specific date in the future. This was working fine until daylight savings time came in to effect and now the Hangfire server seems to be adding an extra hour on to the datetime that a job is scheduled for. e.g. my application will set the time for the background job to be executed at to 17:45 (GMT+1) but Hangfire will schedule the job to be ran at 18:45 instead.
This only happens in a production environment that is configured as an app service in Northern Europe in Azure. The scheduled time is set correctly when running through my local machine. I’m convinced it is something to do with the timezone of the production app service or something that I haven’t configured on Hangfire start up. I have tried multiple different bits of code including a check for DST and then subtracting an hour from the scheduled time, changing the BackgroundJob.Schedule method to use the TimeZone parameters instead of DateTimeOffset and also converting the schedule date to UTC first. All of these have the same outcome of the job being scheduled an hour later than intended.
Please see my invocation of the delayed job function below:
var jobID = BackgroundJob.Schedule(() => GenericMethod(userID, customerID, null), scheduledDate);
where scheduledDate is a DateTime object.
Any help would be greatly appreciated. Thanks.