From 163b059c112d7c5eceb8a1cc1db55184855903df Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Mon, 31 Jul 2023 12:10:50 -0700 Subject: [PATCH] enh: use datetime Signed-off-by: Christopher Ng --- apps/files_reminders/lib/Command/ListCommand.php | 3 +-- apps/files_reminders/lib/Db/Reminder.php | 7 ++++--- .../lib/Migration/Version10000Date20230725162149.php | 5 +++-- apps/files_reminders/lib/Service/ReminderService.php | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/apps/files_reminders/lib/Command/ListCommand.php b/apps/files_reminders/lib/Command/ListCommand.php index 35a778e87d1..f284be5bf2a 100644 --- a/apps/files_reminders/lib/Command/ListCommand.php +++ b/apps/files_reminders/lib/Command/ListCommand.php @@ -26,7 +26,6 @@ declare(strict_types=1); namespace OCA\FilesReminders\Command; -use DateTime; use DateTimeInterface; use OC\Core\Command\Base; use OCA\FilesReminders\Model\RichReminder; @@ -81,7 +80,7 @@ class ListCommand extends Base { fn (RichReminder $reminder) => [ $reminder->getUserId(), $reminder->getNode()->getPath(), - DateTime::createFromFormat('U', (string)$reminder->getRemindAt())->format(DateTimeInterface::ATOM), // ISO 8601 + $reminder->getRemindAt()->format(DateTimeInterface::ATOM), // ISO 8601 $reminder->getNotified() ? 'true' : 'false', ], $reminders, diff --git a/apps/files_reminders/lib/Db/Reminder.php b/apps/files_reminders/lib/Db/Reminder.php index 99cd9b59092..fd20fb45f46 100644 --- a/apps/files_reminders/lib/Db/Reminder.php +++ b/apps/files_reminders/lib/Db/Reminder.php @@ -26,6 +26,7 @@ declare(strict_types=1); namespace OCA\FilesReminders\Db; +use DateTime; use OCP\AppFramework\Db\Entity; /** @@ -35,8 +36,8 @@ use OCP\AppFramework\Db\Entity; * @method void setFileId(int $fileId) * @method int getFileId() * - * @method void setRemindAt(int $remindAt) - * @method int getRemindAt() + * @method void setRemindAt(DateTime $remindAt) + * @method DateTime getRemindAt() * * @method void setNotified(bool $notified) * @method bool getNotified() @@ -50,7 +51,7 @@ class Reminder extends Entity { public function __construct() { $this->addType('userId', 'string'); $this->addType('fileId', 'integer'); - $this->addType('remindAt', 'integer'); + $this->addType('remindAt', 'datetime'); $this->addType('notified', 'boolean'); } } diff --git a/apps/files_reminders/lib/Migration/Version10000Date20230725162149.php b/apps/files_reminders/lib/Migration/Version10000Date20230725162149.php index ab0afd5aec6..6a8cb783931 100644 --- a/apps/files_reminders/lib/Migration/Version10000Date20230725162149.php +++ b/apps/files_reminders/lib/Migration/Version10000Date20230725162149.php @@ -55,9 +55,10 @@ class Version10000Date20230725162149 extends SimpleMigrationStep { $table->addColumn('file_id', Types::BIGINT, [ 'notnull' => true, 'length' => 20, + 'unsigned' => true, ]); - $table->addColumn('remind_at', Types::BIGINT, [ - 'notnull' => true, + $table->addColumn('remind_at', Types::DATETIME, [ + 'notnull' => false, ]); $table->addColumn('notified', Types::BOOLEAN, [ 'notnull' => false, diff --git a/apps/files_reminders/lib/Service/ReminderService.php b/apps/files_reminders/lib/Service/ReminderService.php index e65cdbfb867..8411cdb9cf7 100644 --- a/apps/files_reminders/lib/Service/ReminderService.php +++ b/apps/files_reminders/lib/Service/ReminderService.php @@ -90,7 +90,7 @@ class ReminderService { ->setUser($user->getUID()) ->setObject('reminder', (string)$reminder->getId()) ->setSubject('reminder-due') - ->setDateTime(DateTime::createFromFormat('U', (string)$reminder->getRemindAt())); + ->setDateTime($reminder->getRemindAt()); try { $this->notificationManager->notify($notification); -- 2.39.5