]> source.dussan.org Git - nextcloud-server.git/commitdiff
enh: use datetime
authorChristopher Ng <chrng8@gmail.com>
Mon, 31 Jul 2023 19:10:50 +0000 (12:10 -0700)
committerChristopher Ng <chrng8@gmail.com>
Thu, 3 Aug 2023 22:30:11 +0000 (15:30 -0700)
Signed-off-by: Christopher Ng <chrng8@gmail.com>
apps/files_reminders/lib/Command/ListCommand.php
apps/files_reminders/lib/Db/Reminder.php
apps/files_reminders/lib/Migration/Version10000Date20230725162149.php
apps/files_reminders/lib/Service/ReminderService.php

index 35a778e87d1860ddc5b99dfccffa28f0939f3a0a..f284be5bf2a5f7f9b6167045b15c03c8d905007a 100644 (file)
@@ -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,
index 99cd9b590922cc8631b0911c0386184aaec8faa8..fd20fb45f4620940e84999d71fef9f450f4f3b13 100644 (file)
@@ -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');
        }
 }
index ab0afd5aec6bce817f427c9bb468db43168c75f9..6a8cb783931c5d342725f5bc5eade8f431273941 100644 (file)
@@ -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,
index e65cdbfb86723c8498c30f52527d123aa18051e4..8411cdb9cf743d26cf314258f04743c53b3688a7 100644 (file)
@@ -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);