jobbrIO / jobbr-server

Jobbr is a non-invasive .NET JobServer
https://jobbr.readthedocs.io
GNU General Public License v3.0
50 stars 5 forks source link

Request to support running on server local time instead of UTC time zone #109

Open SamTeong opened 4 months ago

SamTeong commented 4 months ago

Currently IDateTimeProvider is only implemented by UtcNowTimeProvider and exposes method for GetUtcNow() which is used extensively in Scheduling logic. Would it be possible to extend to support running on server local time instead?

eXpl0it3r commented 4 months ago

Hey Sam! 👋

The decision to use UTC everywhere was intentional and there's currently no support for other time zones.
It's a bit of a philosophical discussion whether server software should run/use something other than UTC.

I don't know what it would take to change that approach, but I think we can differentiate between two options:

I feel like the first option is more suited.

SamTeong commented 4 months ago

Ah, unfortunately, the issue we're facing is not for UI display, but rather alignment of the Jobbr scheduling with other job scheduling systems which run on CET (Central European Time) time zone. Due to Daylight Saving Time, CET can vary between UTC+1 and UTC+2.

eXpl0it3r commented 4 months ago

Seems the providers are registered and injected, as such it would be possible to use a different provider implementation.

The main question is, how could this be configured and where. I'm open for suggestions, if you want to think of a design.

SamTeong commented 4 months ago

Would it be that simple to just inject a time provider different from UtcNowTimeProvider? IDateTimeProvider would need to be updated to expose GetNow() instead (for consistency). DateTime.UtcNow is used in JobService, JobRunService, DefaultScheduler. Names with UtcNow would need to be updated. Tests would need to be modified.

SamTeong commented 4 months ago

As for dependency injection, there's Jobbr.Server.Builder.JobbrBuilder.Add() which can be used by end users to inject the instance type of IDateTimeProvider