From d734e21997cf1a7260c50cc9fb75d76c98731666 Mon Sep 17 00:00:00 2001 From: Thomas P Date: Fri, 7 Apr 2023 15:17:21 +0200 Subject: [PATCH] fix(VAlarm) Alarm related to DTSTART of VTODO Following RFC 5545 the start of a VTODO is DTSTART not DUE Fixing the tests in consequence --- lib/Component/VAlarm.php | 8 +------- tests/VObject/Component/VAlarmTest.php | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/Component/VAlarm.php b/lib/Component/VAlarm.php index 3e5797b0a..abe61768e 100644 --- a/lib/Component/VAlarm.php +++ b/lib/Component/VAlarm.php @@ -39,13 +39,7 @@ public function getEffectiveTriggerTime(): \DateTimeImmutable /** @var VEvent|VTodo $parentComponent */ $parentComponent = $this->parent; if ('START' === $related) { - if ('VTODO' === $parentComponent->name) { - $propName = 'DUE'; - } else { - $propName = 'DTSTART'; - } - - $effectiveTrigger = $parentComponent->$propName->getDateTime(); + $effectiveTrigger = $parentComponent->DTSTART->getDateTime(); } else { if ('VTODO' === $parentComponent->name) { $endProp = 'DUE'; diff --git a/tests/VObject/Component/VAlarmTest.php b/tests/VObject/Component/VAlarmTest.php index 4694d6363..a67991ff4 100644 --- a/tests/VObject/Component/VAlarmTest.php +++ b/tests/VObject/Component/VAlarmTest.php @@ -123,6 +123,19 @@ public function timeRangeTestData(): array $tests[] = [$valarm7, new \DateTime('2012-02-25 01:00:00'), new \DateTime('2012-03-05 01:00:00'), true]; $tests[] = [$valarm7, new \DateTime('2012-03-25 01:00:00'), new \DateTime('2012-04-05 01:00:00'), false]; + // Relation to start time of todo + $valarm8 = $calendar->createComponent('VALARM'); + $valarm8->TRIGGER = '-P1D'; + $valarm8->TRIGGER['VALUE'] = 'DURATION'; + + $vtodo8 = $calendar->createComponent('VTODO'); + $vtodo8->DTSTART = '20120301T130000Z'; + $vtodo8->DUE = '20120401T130000Z'; + $vtodo8->add($valarm8); + + $tests[] = [$valarm8, new \DateTime('2012-02-25 01:00:00'), new \DateTime('2012-03-05 01:00:00'), true]; + $tests[] = [$valarm8, new \DateTime('2012-03-25 01:00:00'), new \DateTime('2012-04-05 01:00:00'), false]; + return $tests; } @@ -151,7 +164,7 @@ public function testInTimeRangeBuggy(): void DTSTAMP:20121003T064931Z UID:b848cb9a7bb16e464a06c222ca1f8102@examle.com STATUS:NEEDS-ACTION -DUE:20121005T000000Z +DTSTART:20121005T000000Z SUMMARY:Task 1 CATEGORIES:AlarmCategory BEGIN:VALARM