Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] during daylight saving time change Cronical sleep for one hour #26

Open
StefanoTesla opened this issue Oct 28, 2024 · 6 comments
Open

Comments

@StefanoTesla
Copy link

If this repo is the Cronical that is included in Laragon we have a problem.

https://github.com/leokhoa/laragon/issues/898

I have a laravel application and I use cronical installed as service (I'm on windows) to make the scheduler running.

When daylight saving time ends in winter, the clocks go back from 3:00 to 2:00, meaning we experience the 2 hour twice.

What append:

2024-10-27 02:57:00.943       [10] Starting job: C:\laragon\www\ascomconnector\schedule.bat
2024-10-27 02:58:01.708       [21] Starting job: C:\laragon\www\ascomconnector\schedule.bat
2024-10-27 02:59:01.494       [20] Starting job: C:\laragon\www\ascomconnector\schedule.bat
2024-10-27 03:00:01.352       [20] Starting job: C:\laragon\www\ascomconnector\schedule.bat
2024-10-27 03:01:01.136       [21] Starting job: C:\laragon\www\ascomconnector\schedule.bat
2024-10-27 03:02:00.903       [10] Starting job: C:\laragon\www\ascomconnector\schedule.bat

What I expected:

2024-10-27 02:57:00.943       [10] Starting job: C:\laragon\www\ascomconnector\schedule.bat
2024-10-27 02:58:01.708       [21] Starting job: C:\laragon\www\ascomconnector\schedule.bat
2024-10-27 02:59:01.494       [20] Starting job: C:\laragon\www\ascomconnector\schedule.bat
-----HERE ANOTHER 2:XX HOUR BUT CRONICAL SLEEP-----
2024-10-27 03:00:01.352       [20] Starting job: C:\laragon\www\ascomconnector\schedule.bat
2024-10-27 03:01:01.136       [21] Starting job: C:\laragon\www\ascomconnector\schedule.bat
2024-10-27 03:02:00.903       [10] Starting job: C:\laragon\www\ascomconnector\schedule.bat
@StefanoTesla
Copy link
Author

StefanoTesla commented Oct 29, 2024

I'm a noob in C#, but looking around everyone talk about problems using DateTime looking to the MSDN documentation:

Conversion operations between time zones (such as between UTC and local time, or between one time zone and another) take daylight saving time into account, but arithmetic and comparison operations do not.

From what I'm reading everyone suggest to implement Noda Time library

@mgefvert
Copy link
Owner

Hi! Cronical is not currently under active development. Having said that, I might possibly be able to find some time to look at it, but I can't guarantee the time frame, unless you're able to submit a patch or pull request yourself.

NodaTime is an excellent library, but it doesn't magically solve the problem that there is, actually, a 2:30am happening twice on that day.

One possible solution would be to express time internally as UTC inside Cronical, and keep converting input and output data to and from that. This would ensure that time is strictly sequential in the internal classes; however, it may have some unforeseen side effects (I'll have to think through exactly what that means).

Another is to simply keep track of DST transitions and, like you suggested, refuse to run jobs through that interval - this may be the cleanest solution actually.

@StefanoTesla
Copy link
Author

I read about that library but I don't know if it's right or not.

Anyway I think the best approach is to express time internally as UTC, if for example I want to run a job at 2.30 during DTS for sure it will be handled just one time, please explain const...

I can track dts, but in the case the time come back like in October the cronical don't run, but it should run....when we pass the hour probably we don't have this problem cause he will see actual time > then wait time

@StefanoTesla
Copy link
Author

I tried to open the project with vscode, but I can't find the DotNetCommons can you help me?

@mgefvert
Copy link
Owner

DotNetCommons is another repository of mine; but it should be available as a git submodule - if you fork the repository and make sure to recurse into submodules, you should be getting it properly. Personally I'd recommend JetBrains Rider over vscode, it's supposed to be free now for noncommercial work.

@alxndr-w
Copy link

alxndr-w commented Jan 9, 2025

Maybe, as a workaround, a cron that updates the cron-file right at 03:00:00 daylight saving day will bring Cronical to just continue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants