Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Alarm related to DTSTART of VTODO #616

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 1 addition & 7 deletions lib/Component/VAlarm.php
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
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:b848cb9a7bb16e464a06c222ca1f8102@examle.com
STATUS:NEEDS-ACTION
DUE:20121005T000000Z
DTSTART:20121005T000000Z
SUMMARY:Task 1
CATEGORIES:AlarmCategory
BEGIN:VALARM
Expand Down