Scheduled jobs and daylight saving time

Vote:
 

This has been mentioned before, f.ex. https://world.episerver.com/forum/developer-forum/Problems-and-bugs/Thread-Container/2018/4/scheduled-jobs-and-daylight-saving-time/ and I have seen the response by the CMS developers: https://support.episerver.com/hc/en-us/articles/115004106143-Scheduled-Jobs-and-Time-Changes

For our customer, depending on some jobs being run at a specific time of day (local time) this is a problem. I understand that the jobs run on time (UTC time) but your average web editor do not live by UTC.

I suggest you make the jobs run at the same time of the day (local time) all year. Or make it a site setting so we can choose how daylight saving time are handled regarding to schduled jobs, UTC or local time.

I do really hope I do not have to make a sheduled job that updates the NextExec column in tblScheduledItem based on daylight saving time adjustments.

#191864
May 02, 2018 8:49
Vote:
 

ah.. date and time domain.. :) i'm tired and wish some day everyone will live in UTC

#191981
May 03, 2018 12:17
Vote:
 

Of course with that approach you will almost certainly get jobs that are run twice a night once a year and not at all once a year. cry

#192027
May 03, 2018 17:02
Vote:
 

Why? When a scheduled job is run, the value in the column NextExec in the database table tblScheduledItem get its value updated. 

If adjustment for daylight saving time is taken into account when NextExec is updated, this should be possible without the kind of problems you describe.

For jobs where a fixed interval (f.ex every 24hours) is required, it should still be possible to run the jobs by UTC time.

#192036
Edited, May 03, 2018 21:03
Vote:
 

I can't see how something like this will make some jobs run twice, or not at all, once a year...

    public void RunMyScheduledJob()
    {
        var nextExecFromDatabaseLocal = GetNextExecTime();
        // RunJobIfTimeIsInThePast(nextExecFromDatabaseLocal);
        var newNextExecTimeUTC = CalculateNextExecTime(nextExecFromDatabaseLocal, new TimeSpan(1, 0, 0, 0)); // 1 day
        // UpdateDatabaseWithNewTimeUtc(newNextExecTimeUTC);
    }

    // Display this value in the UI, local time
    private DateTime GetNextExecTime()
    {
        var nextExecFromDatabaseUTC = new DateTime(2018, 3, 24, 11, 0, 0, DateTimeKind.Utc); // 24. march 2018, 11:00 UTV
        var nextExecFromDatabaseLocal = nextExecFromDatabaseUTC.ToLocalTime();
        return nextExecFromDatabaseLocal;
    }

    private DateTime CalculateNextExecTime(DateTime lastExecutedLocal, TimeSpan interval)
    {
        var nextExecutedLocal = lastExecutedLocal + interval;
        var nextExecutedUTC = nextExecutedLocal.ToUniversalTime();
        return nextExecutedUTC;
    }
#192044
May 04, 2018 7:47
Vote:
 

Correct, if adjustments are done for next execution. That wasn't clear in your OP.

Now I am even more confused about what you actually request, you no longer wishes all jobs to be run in local time or having a site-setting dictating local/UTC but rather controlling it differently for each job?

#192062
May 04, 2018 14:37
Vote:
 

I just want to schedule my jobs by local time.

That can be implemented in a number of ways. Some examples:

  • Always run jobs by local time
  • Let a global setting select local time or UTC
  • Let a setting for earch scheduled job select local time or UTC
#192084
Edited, May 05, 2018 16:18
This thread is locked and should be used for reference only.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.