Merge pull request #17172 from nextcloud/backport/17159/stable17

[stable17] Sabre/VObject returns a DateAndOrTime object now, so adapt to it in Birthday service
This commit is contained in:
Roeland Jago Douma 2019-09-19 21:31:24 +02:00 committed by GitHub
commit db51d166b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -243,7 +243,11 @@ class BirthdayService {
} }
try { try {
$date = new \DateTime($birthday); if ($birthday instanceof DateAndOrTime) {
$date = $birthday->getDateTime();
} else {
$date = new \DateTimeImmutable($birthday);
}
} catch (Exception $e) { } catch (Exception $e) {
return null; return null;
} }
@ -259,10 +263,13 @@ class BirthdayService {
); );
$vEvent->DTSTART['VALUE'] = 'DATE'; $vEvent->DTSTART['VALUE'] = 'DATE';
$vEvent->add('DTEND'); $vEvent->add('DTEND');
$date->add(new \DateInterval('P1D'));
$dtEndDate = (new \DateTime())->setTimestamp($date->getTimeStamp());
$dtEndDate->add(new \DateInterval('P1D'));
$vEvent->DTEND->setDateTime( $vEvent->DTEND->setDateTime(
$date $dtEndDate
); );
$vEvent->DTEND['VALUE'] = 'DATE'; $vEvent->DTEND['VALUE'] = 'DATE';
$vEvent->{'UID'} = $doc->UID . $postfix; $vEvent->{'UID'} = $doc->UID . $postfix;
$vEvent->{'RRULE'} = 'FREQ=YEARLY'; $vEvent->{'RRULE'} = 'FREQ=YEARLY';
@ -306,7 +313,7 @@ class BirthdayService {
foreach($books as $book) { foreach($books as $book) {
$cards = $this->cardDavBackEnd->getCards($book['id']); $cards = $this->cardDavBackEnd->getCards($book['id']);
foreach($cards as $card) { foreach($cards as $card) {
$this->onCardChanged($book['id'], $card['uri'], $card['carddata']); $this->onCardChanged((int) $book['id'], $card['uri'], $card['carddata']);
} }
} }
} }