Skip to content

Fix Introduce a timezoneOffsetService for proposal and fix DST problem #8083

Open
taiebot wants to merge 18 commits intonextcloud:mainfrom
taiebot:Anothertry
Open

Fix Introduce a timezoneOffsetService for proposal and fix DST problem #8083
taiebot wants to merge 18 commits intonextcloud:mainfrom
taiebot:Anothertry

Conversation

@taiebot
Copy link
Copy Markdown
Contributor

@taiebot taiebot commented Mar 21, 2026

Hello all,

Thank you all for this amazing project. I did another pull request which works as well but i think it might have been not that easy to review.

Trying to fix #8040
Be aware that this is my 1st time contributing to a project like Nextcloud and i am not a developer. This work is entirely done with an AI with vibe coding over weekends. Test it carefully to see if it does not break anything else. I tried to be as close as the original code.
I introduce a timezoneOffsetService which allows to reuse it in the two parts of the code.

I managed to test this with https://github.com/szaimen/nextcloud-easy-test and what i could see and looks like it is fixed. 🤯

See original problem in #8040

With this PR

Screenshot 2026-03-20 at 23-20-05 March 2026 - Agenda - Nextcloud Screenshot 2026-03-20 at 23-19-43 March 2026 - Agenda - Nextcloud

On main
Screenshot 2026-03-20 at 23-45-58 March 2026 - Agenda - Nextcloud

Screenshot 2026-03-20 at 23-46-34 March 2026 - Agenda - Nextcloud

Ai comparison old vs new

The old code derives the timezone offset by converting dates to locale‑formatted strings and back, which is fragile and can mis-handle daylight‑saving transitions because the string round‑trip doesn’t reliably preserve DST rules. It also depends on the system’s locale parsing behavior, which varies across environments and can introduce subtle bugs. The new code avoids these pitfalls by using Intl.DateTimeFormat with formatToParts, which is explicitly designed to respect each timezone’s DST rules. Instead of relying on string parsing, it reconstructs the exact local time components and computes the UTC equivalent using Date.UTC, producing a precise offset even during DST boundaries. The new version caches formatters for performance, while the old version recreates them on every call. Error handling also improves: the old code returns 0 on failure, masking errors, whereas the new code returns null, making issues detectable. Overall, the new implementation is more robust, DST‑safe, locale‑independent, and efficient.

taiebot added 5 commits March 21, 2026 21:01
Signed-off-by: taiebot <dedreuil@yahoo.fr>
Replaced manual timezone offset calculation with a call to getTimezoneOffset function.

Signed-off-by: taiebot <dedreuil@yahoo.fr>
Refactor timezone handling by removing timezoneOffset state and using getTimezoneOffset function directly in date calculations.

Signed-off-by: taiebot <dedreuil@yahoo.fr>
Remove TypeScript type annotations from getTimezoneOffset function.

Signed-off-by: taiebot <dedreuil@yahoo.fr>
Signed-off-by: taiebot <dedreuil@yahoo.fr>
Signed-off-by: taiebot <dedreuil@yahoo.fr>
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Follow up cache the timezoneId formatter and floor instead of round

Signed-off-by: taiebot <dedreuil@yahoo.fr>
@taiebot taiebot changed the title Introduce a timezoneOffsetService for proposal and fix DST problem Fix Introduce a timezoneOffsetService for proposal and fix DST problem Mar 22, 2026
taiebot added 5 commits March 23, 2026 18:24
Signed-off-by: taiebot <dedreuil@yahoo.fr>
Eslint 

Signed-off-by: taiebot <dedreuil@yahoo.fr>
Try to  fix those things ...

Signed-off-by: taiebot <dedreuil@yahoo.fr>
Add error handling to timezone offset calculation

Signed-off-by: taiebot <dedreuil@yahoo.fr>
Copy link
Copy Markdown
Contributor

@GVodyanov GVodyanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello! We really appreciate your PR for such an annoying issue, good job!

I see that you are having some struggles with ESLint, if you like I could fix that for you seeing as from what I can see vibe coding wasn't able to do that.

Just wanted to mention that we actually have a timezone library which might be useful here: https://github.com/nextcloud-libraries/timezones

@taiebot
Copy link
Copy Markdown
Contributor Author

taiebot commented Mar 26, 2026

Hi @GVodyanov please feel free to fix those Linting errors they are driving mad 😠 . I am doing all this directly with the github web interface and it is not giving me any feedback until this is tested by the CI job.
I tried last night to set my self a proper working environment with Vscodium but even there i am having difficulty at setting up this environment properly.

About the timezones library comment i do not grasp the relevance. What should i do ? Do i need to do anything ?

I tried specifically to keep things as simple as i could.

My main goal was :

  • to not bring any libraries : (AI kept suggesting tz.moment or others)
  • Keep the code as much as possible close to the current logic (easier for review) even if some other suggestions could have been better fixes 8040 proposal DST issues #8080 works but felt too different from original logic.
  • Use a function because both parts were similar
  • Cross checked the functions and code logic with multiple AIs.
  • Tested with https://github.com/szaimen/nextcloud-easy-test => previous versions were not tested. Note you need to refresh the browser Ctrl + Shift + R at first install to see the changes

Found another bug while testing this as well will report it and see if i can also do something about it.

Thanks again ✌️

@taiebot
Copy link
Copy Markdown
Contributor Author

taiebot commented Mar 31, 2026

Note this bug is not triggered for current dates => Next events will get weird around 25 oct 2026 - Daylight Saving Time Ends

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 5, 2026

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

taiebot added 4 commits April 8, 2026 22:23
Signed-off-by: taiebot <dedreuil@yahoo.fr>
Signed-off-by: taiebot <dedreuil@yahoo.fr>
Signed-off-by: taiebot <dedreuil@yahoo.fr>
@SebastianKrupinski
Copy link
Copy Markdown
Contributor

Hi @taiebot

Thank you for the PR, I will review it when I get a few spare minutes

@taiebot
Copy link
Copy Markdown
Contributor Author

taiebot commented Apr 9, 2026

👍 feel free to take it from here. Hopefully it will not be a waste of your time. Just let me know if those AI tested contributions are worth it or if the code quality is subpar and you end up with more corrections than actual contribution I will keep my job of reporting bugs... ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DST (Daylight saving time) errors whenever the proposal date is in a different DST period than the current date.

3 participants