Skip to content

Commit

Permalink
Use ISO Year within WEEKLY recurrence handling
Browse files Browse the repository at this point in the history
When setting the date for an occurrence of a recurring event where the `RRULE`
has a frequency of `WEEKLY` and `BYDAY` was used, the `setISODate()` method is
used.

Unfortunately, I had used `Y` instead of `o` as the date format code for getting
the current year, thus feeding the Gregorian year instead of the ISO year into
the method.

This was causing some year-start/end edge-case errors, as described in #251.

Essentially, I was committing the opposite of the error that Twitter is thought
to have made in late 2014, as described in this video by Tom Scott:
https://www.youtube.com/watch?v=D3jxx8Yyw1c (They should have used Gregorian and
were using ISO, we should have been using ISO and were using Gregorian.)
  • Loading branch information
s0600204 committed Jan 17, 2020
1 parent ec0773e commit 6aae51e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/ICal/ICal.php
Original file line number Diff line number Diff line change
Expand Up @@ -1397,7 +1397,7 @@ function ($weekday) use ($initialDayOfWeek, $wkstTransition, $interval) {
foreach ($matchingDays as $day) {
$clonedDateTime = clone $frequencyRecurringDateTime;
$candidateDateTimes[] = $clonedDateTime->setISODate(
$frequencyRecurringDateTime->format('Y'),
$frequencyRecurringDateTime->format('o'),
$frequencyRecurringDateTime->format('W'),
$day
);
Expand Down

0 comments on commit 6aae51e

Please sign in to comment.