Skip to content

Commit 3e1e0d3

Browse files
authored
Merge pull request #616 from tpayen/fix/valarm-vtodo
Fix Alarm related to DTSTART of VTODO
2 parents ad1a838 + d734e21 commit 3e1e0d3

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

lib/Component/VAlarm.php

+1-7
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,7 @@ public function getEffectiveTriggerTime(): \DateTimeImmutable
3939
/** @var VEvent|VTodo $parentComponent */
4040
$parentComponent = $this->parent;
4141
if ('START' === $related) {
42-
if ('VTODO' === $parentComponent->name) {
43-
$propName = 'DUE';
44-
} else {
45-
$propName = 'DTSTART';
46-
}
47-
48-
$effectiveTrigger = $parentComponent->$propName->getDateTime();
42+
$effectiveTrigger = $parentComponent->DTSTART->getDateTime();
4943
} else {
5044
if ('VTODO' === $parentComponent->name) {
5145
$endProp = 'DUE';

tests/VObject/Component/VAlarmTest.php

+14-1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,19 @@ public function timeRangeTestData(): array
123123
$tests[] = [$valarm7, new \DateTime('2012-02-25 01:00:00'), new \DateTime('2012-03-05 01:00:00'), true];
124124
$tests[] = [$valarm7, new \DateTime('2012-03-25 01:00:00'), new \DateTime('2012-04-05 01:00:00'), false];
125125

126+
// Relation to start time of todo
127+
$valarm8 = $calendar->createComponent('VALARM');
128+
$valarm8->TRIGGER = '-P1D';
129+
$valarm8->TRIGGER['VALUE'] = 'DURATION';
130+
131+
$vtodo8 = $calendar->createComponent('VTODO');
132+
$vtodo8->DTSTART = '20120301T130000Z';
133+
$vtodo8->DUE = '20120401T130000Z';
134+
$vtodo8->add($valarm8);
135+
136+
$tests[] = [$valarm8, new \DateTime('2012-02-25 01:00:00'), new \DateTime('2012-03-05 01:00:00'), true];
137+
$tests[] = [$valarm8, new \DateTime('2012-03-25 01:00:00'), new \DateTime('2012-04-05 01:00:00'), false];
138+
126139
return $tests;
127140
}
128141

@@ -151,7 +164,7 @@ public function testInTimeRangeBuggy(): void
151164
DTSTAMP:20121003T064931Z
152165
153166
STATUS:NEEDS-ACTION
154-
DUE:20121005T000000Z
167+
DTSTART:20121005T000000Z
155168
SUMMARY:Task 1
156169
CATEGORIES:AlarmCategory
157170
BEGIN:VALARM

0 commit comments

Comments
 (0)