Skip to content

Commit

Permalink
Merge pull request #616 from tpayen/fix/valarm-vtodo
Browse files Browse the repository at this point in the history
Fix Alarm related to DTSTART of VTODO
  • Loading branch information
phil-davis authored Aug 28, 2024
2 parents ad1a838 + d734e21 commit 3e1e0d3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
8 changes: 1 addition & 7 deletions lib/Component/VAlarm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
15 changes: 14 additions & 1 deletion tests/VObject/Component/VAlarmTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -151,7 +164,7 @@ public function testInTimeRangeBuggy(): void
DTSTAMP:20121003T064931Z
UID:[email protected]
STATUS:NEEDS-ACTION
DUE:20121005T000000Z
DTSTART:20121005T000000Z
SUMMARY:Task 1
CATEGORIES:AlarmCategory
BEGIN:VALARM
Expand Down

0 comments on commit 3e1e0d3

Please sign in to comment.