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

Add value type DATE to DTSTART and DTEND #519

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions src/Presentation/Factory/EventFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,31 @@ protected function getComponents(Event $event): Generator
private function getOccurrenceProperties(Occurrence $occurrence): Generator
{
if ($occurrence instanceof SingleDay) {
yield new Property('DTSTART', new DateValue($occurrence->getDate()));
yield new Property(
'DTSTART',
new DateValue($occurrence->getDate()),
[
new Parameter('VALUE', new TextValue('DATE')),
]
);
}

if ($occurrence instanceof MultiDay) {
yield new Property('DTSTART', new DateValue($occurrence->getFirstDay()));
yield new Property('DTEND', new DateValue($occurrence->getLastDay()->add(new DateInterval('P1D'))));
yield new Property(
'DTSTART',
new DateValue($occurrence->getFirstDay()),
[
new Parameter('VALUE', new TextValue('DATE')),
]
);

yield new Property(
'DTEND',
new DateValue($occurrence->getLastDay()->add(new DateInterval('P1D'))),
[
new Parameter('VALUE', new TextValue('DATE')),
]
);
}

if ($occurrence instanceof TimeSpan) {
Expand Down
6 changes: 3 additions & 3 deletions tests/Integration/EventsGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,19 @@ public function testEventsGeneratorCreatesIcsContent(): void
'UID:event-0',
'DTSTAMP:20200101T150000Z',
'SUMMARY:Event 0',
'DTSTART:20200101',
'DTSTART;VALUE=DATE:20200101',
'END:VEVENT',
'BEGIN:VEVENT',
'UID:event-1',
'DTSTAMP:20200101T150000Z',
'SUMMARY:Event 1',
'DTSTART:20200102',
'DTSTART;VALUE=DATE:20200102',
'END:VEVENT',
'BEGIN:VEVENT',
'UID:event-2',
'DTSTAMP:20200101T150000Z',
'SUMMARY:Event 2',
'DTSTART:20200103',
'DTSTART;VALUE=DATE:20200103',
'END:VEVENT',
'END:VCALENDAR',
];
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Presentation/Factory/EventFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function testSingleDayEvent()
$event = (new Event())->setOccurrence(new SingleDay(new Date(DateTimeImmutable::createFromFormat('Y-m-d', '2030-12-24'))));

self::assertEventRendersCorrect($event, [
'DTSTART:20301224',
'DTSTART;VALUE=DATE:20301224',
]);
}

Expand All @@ -122,8 +122,8 @@ public function testMultiDayEvent()
$event = (new Event())->setOccurrence($occurrence);

self::assertEventRendersCorrect($event, [
'DTSTART:20301224',
'DTEND:20301227',
'DTSTART;VALUE=DATE:20301224',
'DTEND;VALUE=DATE:20301227',
]);
}

Expand Down