diff --git a/lib/Db/Card.php b/lib/Db/Card.php index 674ee8f8a..ed710d716 100644 --- a/lib/Db/Card.php +++ b/lib/Db/Card.php @@ -108,7 +108,7 @@ class Card extends RelationalEntity { $this->addType('archived', 'boolean'); $this->addType('notified', 'boolean'); $this->addType('deletedAt', 'integer'); - $this->addType('duedate', 'string'); + $this->addType('duedate', 'datetime'); $this->addRelation('labels'); $this->addRelation('assignedUsers'); $this->addRelation('attachments'); @@ -126,20 +126,6 @@ class Card extends RelationalEntity { $this->databaseType = $type; } - public function getDueDateTime(): ?DateTime { - return $this->duedate ? new DateTime($this->duedate) : null; - } - - public function getDuedate($isoFormat = false): ?string { - $dt = $this->getDueDateTime(); - $format = 'c'; - if (!$isoFormat && $this->databaseType === 'mysql') { - $format = 'Y-m-d H:i:s'; - } - - return $dt ? $dt->format($format) : null; - } - public function getCalendarObject(): VCalendar { $calendar = new VCalendar(); $event = $calendar->createComponent('VTODO'); @@ -148,7 +134,7 @@ class Card extends RelationalEntity { $creationDate = new DateTime(); $creationDate->setTimestamp($this->createdAt); $event->DTSTAMP = $creationDate; - $event->DUE = new DateTime($this->getDuedate(true), new DateTimeZone('UTC')); + $event->DUE = new DateTime($this->getDuedate()->format('c'), new DateTimeZone('UTC')); } $event->add('RELATED-TO', 'deck-stack-' . $this->getStackId()); diff --git a/lib/Db/RelationalEntity.php b/lib/Db/RelationalEntity.php index 6e2a19ef5..8ac6ef456 100644 --- a/lib/Db/RelationalEntity.php +++ b/lib/Db/RelationalEntity.php @@ -72,6 +72,9 @@ class RelationalEntity extends Entity implements \JsonSerializable { $propertyReflection = $reflection->getProperty($property); if (!$propertyReflection->isPrivate() && !in_array($property, $this->_resolvedProperties, true)) { $json[$property] = $this->getter($property); + if ($json[$property] instanceof \DateTimeInterface) { + $json[$property] = $json[$property]->format('c'); + } } } } diff --git a/lib/Model/CardDetails.php b/lib/Model/CardDetails.php index 6c51ef841..58523ab14 100644 --- a/lib/Model/CardDetails.php +++ b/lib/Model/CardDetails.php @@ -54,7 +54,7 @@ class CardDetails extends Card { $today = new DateTime(); $today->setTime(0, 0); - $match_date = $this->card->getDueDateTime(); + $match_date = $this->card->getDuedate(); if (!$match_date) { return Card::DUEDATE_FUTURE; } diff --git a/lib/Notification/NotificationHelper.php b/lib/Notification/NotificationHelper.php index 97b900c73..0105c03f0 100644 --- a/lib/Notification/NotificationHelper.php +++ b/lib/Notification/NotificationHelper.php @@ -129,7 +129,7 @@ class NotificationHelper { ->setSubject('card-overdue', [ $card->getTitle(), $board->getTitle() ]) - ->setDateTime(new DateTime($card->getDuedate())); + ->setDateTime($card->getDuedate()); $this->notificationManager->notify($notification); } } @@ -242,7 +242,7 @@ class NotificationHelper { } return $this->boards[$boardId]; } - + private function generateBoardShared(Board $board, string $userId): INotification { $notification = $this->notificationManager->createNotification(); $notification diff --git a/lib/Service/CardService.php b/lib/Service/CardService.php index 6ee4cf081..cd45ca129 100644 --- a/lib/Service/CardService.php +++ b/lib/Service/CardService.php @@ -337,11 +337,11 @@ class CardService { $card->setType($type); $card->setOrder($order); $card->setOwner($owner); - $card->setDuedate($duedate); + $card->setDuedate(new \DateTime($duedate)); $resetDuedateNotification = false; if ( $card->getDuedate() === null || - (new \DateTime($card->getDuedate())) != (new \DateTime($changes->getBefore()->getDuedate() ?? '')) + ($card->getDuedate()) != ($changes->getBefore()->getDuedate()) ) { $card->setNotified(false); $resetDuedateNotification = true;