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

fix: handle timezones with no transitions properly #6478

Merged
merged 1 commit into from
Nov 11, 2024

Conversation

SebastianKrupinski
Copy link
Contributor

Resolves: #6476

Testing: See issue ticket for details.

Copy link

codecov bot commented Nov 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 23.48%. Comparing base (9d1688c) to head (991402f).
Report is 30 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #6478      +/-   ##
============================================
+ Coverage     23.47%   23.48%   +0.01%     
- Complexity      453      454       +1     
============================================
  Files           247      247              
  Lines         11712    11711       -1     
  Branches       2222     2223       +1     
============================================
+ Hits           2749     2750       +1     
+ Misses         8643     8641       -2     
  Partials        320      320              
Flag Coverage Δ
javascript 15.05% <ø> (-0.01%) ⬇️
php 59.44% <ø> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@miaulalala
Copy link
Contributor

Can you elaborate why skipping the first (or 0 position) solves the issue please? 🙏

@SebastianKrupinski
Copy link
Contributor Author

Can you elaborate why skipping the first (or 0 position) solves the issue please? 🙏

Morning, sure,

This code actually process the first position, instead of skipping it, the original code, skipped transition 0, which in certain time zones is needed for time zones with static transitions.

Here is a example of how Mexico City time zone was being generated:

Before:

BEGIN:VTIMEZONE
TZID:America/Mexico_City
X-MICROSOFT-CDO-TZID:37
END:VTIMEZONE

After:

BEGIN:VTIMEZONE
TZID:America/Mexico_City
X-MICROSOFT-CDO-TZID:37

BEGIN:STANDARD
TZOFFSETFROM:-0600
TZOFFSETTO:-0600
TZNAME:CST
DTSTART:19700101T000000
END:STANDARD

END:VTIMEZONE

The Mexico City timezone has a single static transition which was being skipped originally, and because the "BEGIN:STANDARD" was missing the timezone was never applied to the event, showing the event off by the amount of the timezone offset.

Copy link
Member

@st3iny st3iny left a comment

Choose a reason for hiding this comment

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

Tested and works.

$offset = $trans['offset'] / 3600;

if ($i === 0) {
$date = new \DateTime('19700101T000000');
Copy link
Member

@st3iny st3iny Nov 11, 2024

Choose a reason for hiding this comment

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

Feels a bit weird to use 1970-01-01 here.

Using $trans['time'] would also work but it can stay as is. It will be equivalent to the requested start date (one year back).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I know it looks odd, but this is how all the other software I have tested handles this, so I thought it would be best stay with the follow. The start year an date does not really matter for static time zones.

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense!

@SebastianKrupinski SebastianKrupinski merged commit 1dd9614 into main Nov 11, 2024
38 checks passed
@SebastianKrupinski SebastianKrupinski deleted the fix/issue-6476-no-transition-timezones branch November 11, 2024 14:02
@backportbot backportbot bot added the backport-request A backport was requested for this pull request label Nov 11, 2024
@nextcloud nextcloud deleted a comment from backportbot bot Nov 11, 2024
@SebastianKrupinski
Copy link
Contributor Author

/backport to stable4.7

@backportbot backportbot bot removed the backport-request A backport was requested for this pull request label Nov 11, 2024
@st3iny st3iny added this to the v5.1.0 milestone Nov 11, 2024
@st3iny
Copy link
Member

st3iny commented Nov 11, 2024

/backport to stable5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ☑️ Done
Development

Successfully merging this pull request may close these issues.

Appointment module does not generate proper time zone definition causing events to display incorrectly
3 participants