Skip to content

fix: keep the exact or nominal duration across DST in getDtEnd() - #820

Open
jvelo wants to merge 2 commits into
sabre-io:masterfrom
jvelo:fix/dtend-across-dst
Open

jvelo wants to merge 2 commits into
sabre-io:masterfrom
jvelo:fix/dtend-across-dst

Conversation

@jvelo

@jvelo jvelo commented Nov 26, 2026 •

Copy link
Copy Markdown

Summary

Fixes #818.

EventIterator::getDtEnd() added the duration in seconds with modify(). PHP applies +N seconds to the clock time, so the end of an instance that crosses a DST transition was wrong. The first instance did not match the DTEND of the event.

RFC 5545, section 3.8.5.3:

  • With DTEND, all instances have the same exact duration. getDtEnd() now adds the seconds to the timestamp.
  • With DURATION, all instances have the same nominal duration. getDtEnd() now adds the DateInterval to the start of each instance, so P1D stays one day across a transition. In a mixed duration such as P1DT2H, the days are nominal and the hours are exact.

Behaviour changes for floating and all-day events

Floating and all-day events with DTEND keep the current behaviour.

With DURATION, the change also applies to floating and all-day events when a reference timezone that observes DST is given to the iterator. For example, with America/New_York:

  • Floating DTSTART:20270306T120000, DURATION:PT24H, weekly: the second instance now ends at 13:00 EDT, before at 12:00 EDT.
  • All-day DTSTART;VALUE=DATE:20270314, DURATION:P1D: the first instance now ends on March 15 at midnight, before on March 14 at 23:00.

Both follow RFC 5545.

Tests

DurationAcrossDstTest covers:

  • DTEND, to summer time and to winter time.
  • DURATION as P1D and PT24H, to summer time and to winter time.
  • DURATION as P1DT2H, to summer time.
  • Floating and all-day events with DURATION and a reference timezone.
  • getEventObject().

It checks the instance that crosses the transition and the one after it. 11 of the 12 cases fail without the change. The full suite and phpstan pass.

getDtEnd() added the duration in seconds with modify(), which uses the
clock time. Across a DST transition, the end was wrong.

With DTEND, each instance now has the exact duration of the master
event. With DURATION, the nominal duration is added to each start, as
RFC 5545, section 3.8.5.3, requires.

Fixes sabre-io#818.
Add winter time cases for P1D and PT24H, a mixed P1DT2H case,
and floating and all-day events with a reference timezone.
@jvelo
jvelo marked this pull request as ready for review November 26, 2026 15:00
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

Successfully merging this pull request may close these issues.

EventIterator::getDtEnd() is incorrect across DST transitions

1 participant