Fix issue with duedate format

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling
2022-10-13 14:57:55 +02:00
committed by backportbot-nextcloud[bot]
parent de67847ef1
commit b74569abef
5 changed files with 10 additions and 21 deletions

View File

@@ -108,7 +108,7 @@ class Card extends RelationalEntity {
$this->addType('archived', 'boolean'); $this->addType('archived', 'boolean');
$this->addType('notified', 'boolean'); $this->addType('notified', 'boolean');
$this->addType('deletedAt', 'integer'); $this->addType('deletedAt', 'integer');
$this->addType('duedate', 'string'); $this->addType('duedate', 'datetime');
$this->addRelation('labels'); $this->addRelation('labels');
$this->addRelation('assignedUsers'); $this->addRelation('assignedUsers');
$this->addRelation('attachments'); $this->addRelation('attachments');
@@ -126,20 +126,6 @@ class Card extends RelationalEntity {
$this->databaseType = $type; $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 { public function getCalendarObject(): VCalendar {
$calendar = new VCalendar(); $calendar = new VCalendar();
$event = $calendar->createComponent('VTODO'); $event = $calendar->createComponent('VTODO');
@@ -148,7 +134,7 @@ class Card extends RelationalEntity {
$creationDate = new DateTime(); $creationDate = new DateTime();
$creationDate->setTimestamp($this->createdAt); $creationDate->setTimestamp($this->createdAt);
$event->DTSTAMP = $creationDate; $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()); $event->add('RELATED-TO', 'deck-stack-' . $this->getStackId());

View File

@@ -72,6 +72,9 @@ class RelationalEntity extends Entity implements \JsonSerializable {
$propertyReflection = $reflection->getProperty($property); $propertyReflection = $reflection->getProperty($property);
if (!$propertyReflection->isPrivate() && !in_array($property, $this->_resolvedProperties, true)) { if (!$propertyReflection->isPrivate() && !in_array($property, $this->_resolvedProperties, true)) {
$json[$property] = $this->getter($property); $json[$property] = $this->getter($property);
if ($json[$property] instanceof \DateTimeInterface) {
$json[$property] = $json[$property]->format('c');
}
} }
} }
} }

View File

@@ -54,7 +54,7 @@ class CardDetails extends Card {
$today = new DateTime(); $today = new DateTime();
$today->setTime(0, 0); $today->setTime(0, 0);
$match_date = $this->card->getDueDateTime(); $match_date = $this->card->getDuedate();
if (!$match_date) { if (!$match_date) {
return Card::DUEDATE_FUTURE; return Card::DUEDATE_FUTURE;
} }

View File

@@ -129,7 +129,7 @@ class NotificationHelper {
->setSubject('card-overdue', [ ->setSubject('card-overdue', [
$card->getTitle(), $board->getTitle() $card->getTitle(), $board->getTitle()
]) ])
->setDateTime(new DateTime($card->getDuedate())); ->setDateTime($card->getDuedate());
$this->notificationManager->notify($notification); $this->notificationManager->notify($notification);
} }
} }
@@ -242,7 +242,7 @@ class NotificationHelper {
} }
return $this->boards[$boardId]; return $this->boards[$boardId];
} }
private function generateBoardShared(Board $board, string $userId): INotification { private function generateBoardShared(Board $board, string $userId): INotification {
$notification = $this->notificationManager->createNotification(); $notification = $this->notificationManager->createNotification();
$notification $notification

View File

@@ -337,11 +337,11 @@ class CardService {
$card->setType($type); $card->setType($type);
$card->setOrder($order); $card->setOrder($order);
$card->setOwner($owner); $card->setOwner($owner);
$card->setDuedate($duedate); $card->setDuedate(new \DateTime($duedate));
$resetDuedateNotification = false; $resetDuedateNotification = false;
if ( if (
$card->getDuedate() === null || $card->getDuedate() === null ||
(new \DateTime($card->getDuedate())) != (new \DateTime($changes->getBefore()->getDuedate() ?? '')) ($card->getDuedate()) != ($changes->getBefore()->getDuedate())
) { ) {
$card->setNotified(false); $card->setNotified(false);
$resetDuedateNotification = true; $resetDuedateNotification = true;