Skip to content

[3.0] feat(ics)!: always name resolvable timezones (align with Google Calendar) - #256

Open
Prakashdahal2005 wants to merge 1 commit into
spatie:masterfrom
Prakashdahal2005:fix-always-name-timezones
Open

[3.0] feat(ics)!: always name resolvable timezones (align with Google Calendar)#256
Prakashdahal2005 wants to merge 1 commit into
spatie:masterfrom
Prakashdahal2005:fix-always-name-timezones

Conversation

@Prakashdahal2005

Copy link
Copy Markdown

Summary

This PR resolves #255 by refactoring the Ics generator to always name resolvable timezones for non-all-day events, bringing its behavior into full alignment with Google::generate().

Previously in v2.x, Ics only named timezones if an RRULE was attached or if the timezone observed daylight saving changes (observesAChange()), flattening other single-zone events to UTC instants (DTSTART:20260323T080000Z). Under v3.0, all resolvable non-all-day events write local times with TZID and output a VTIMEZONE block.

Key Changes

  • Simplified Gate (src/Generators/Ics.php): shouldNameTimezones() now directly returns ! $link->allDay && $link->hasResolvableTimezones().
  • Dead Code Deletion: Removed observesAChange() and its memoization array $observedChanges.
  • Test Suite Updates (tests/Generators/IcsGeneratorTest.php): Updated legacy v2.0 unit test assertions that previously expected plain UTC instants.
  • Snapshots Updated: Regenerated fixture snapshots across timed ICS events to reflect TZID and VTIMEZONE structures.

Breaking Change Notice

This is targeted for v3.0:

  • DTSTART and DTEND for resolvable non-all-day events output local times with TZID parameters instead of UTC instants with a Z suffix.
  • Generated ICS outputs now contain a VTIMEZONE component for resolvable zones.

Verification

  • PHPUnit: 234 tests, 484 assertions — 100% PASS
  • Psalm: 0 errors

…ecurring

- Simplify shouldNameTimezones() to emit TZID + VTIMEZONE for every
  timed event with a resolvable zone, dropping the RRULE gate
- Remove observesAChange() and its memoization
- Update test assertions and snapshots to match v3.0 output

BREAKING CHANGE: DTSTART/DTEND are now local times with a TZID parameter
and an accompanying VTIMEZONE block for all resolvable-zone events.
Previously only recurring events in DST-observing zones received this
treatment; all others were flattened to UTC instants with a trailing Z.
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.

[3.0]: Ics should always name a resolvable timezone, as Google already does

1 participant