November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
ah.. date and time domain.. :) i'm tired and wish some day everyone will live in UTC
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.
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.
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; }
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?
I just want to schedule my jobs by local time.
That can be implemented in a number of ways. Some examples:
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.