I have a simple method where I try to schedule a task to run a single time at a specific hour. Here is my function (a lot of redundant code after testing all types of workarounds)
public string Schedule(Guid id, JobType jobType, DateTime scheduleTime)
{
//DateTime is paresed from a format like this : "2020-05-19T20:50:00Z";
return _backgroundJobClient.Schedule(() => task(), scheduleTime);
}
f I run the above example with date : 2020-05-19T20:50:00Z in Hangfire.State.Data I have:
{"EnqueueAt":"2020-05-19T20:50:00.0000000Z",
"ScheduledAt":"2020-05-19T15:01:16.5174515Z"}
EnqueueAt is fine but ScheduledAt is behind with a few hours. For the database, I am using Postgres and I have set also there the timezone right.
If I schedule a job in the past (a date in the past bigger then 1 day) the task is triggered and all si fine.
Has anybody some idea what I am doing wrong? Thanks