Hangfire wrong date/time saved for ScheduleAt attribute

recurring
Tags: #<Tag:0x00007f64b64b0c68>

#1

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


#2

I could be wrong, but I believe Scheduled At is just the time in which the Job was actually Scheduled at, not the time the Job will run.

What are you expecting vs what are you getting? Seems like your Job is all set to run at
2020-05-19T20:50:00.0000000Z, is it not running at that time?