From 5bd51b156a9798f5afb318b3e75cc609fbf506bd Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 1 Jun 2021 22:32:05 +0000 Subject: [PATCH] API: Fix date format --- src/Object/Api/Mastodon/Account.php | 2 +- src/Object/Api/Mastodon/Notification.php | 2 +- src/Object/Api/Mastodon/Status.php | 2 +- src/Object/Api/Mastodon/Token.php | 2 +- src/Util/DateTimeFormat.php | 5 +++-- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Object/Api/Mastodon/Account.php b/src/Object/Api/Mastodon/Account.php index 358ad4aded..01febcf363 100644 --- a/src/Object/Api/Mastodon/Account.php +++ b/src/Object/Api/Mastodon/Account.php @@ -108,7 +108,7 @@ class Account extends BaseDataTransferObject $userContactCreated = $userContact['created'] ?? DBA::NULL_DATETIME; $created = $userContactCreated < $publicContactCreated && ($userContactCreated != DBA::NULL_DATETIME) ? $userContactCreated : $publicContactCreated; - $this->created_at = DateTimeFormat::utc($created, DateTimeFormat::ATOM); + $this->created_at = DateTimeFormat::utc($created, DateTimeFormat::API); $this->note = BBCode::convert($publicContact['about'], false); $this->url = $publicContact['url']; diff --git a/src/Object/Api/Mastodon/Notification.php b/src/Object/Api/Mastodon/Notification.php index ee4930e3cd..2c2e8d6f9c 100644 --- a/src/Object/Api/Mastodon/Notification.php +++ b/src/Object/Api/Mastodon/Notification.php @@ -52,7 +52,7 @@ class Notification extends BaseDataTransferObject { $this->id = (string)$id; $this->type = $type; - $this->created_at = DateTimeFormat::utc($created_at, DateTimeFormat::ATOM); + $this->created_at = DateTimeFormat::utc($created_at, DateTimeFormat::API); $this->account = $account->toArray(); if (!empty($status)) { diff --git a/src/Object/Api/Mastodon/Status.php b/src/Object/Api/Mastodon/Status.php index 974ac0dc74..f236d2231d 100644 --- a/src/Object/Api/Mastodon/Status.php +++ b/src/Object/Api/Mastodon/Status.php @@ -100,7 +100,7 @@ class Status extends BaseDataTransferObject public function __construct(array $item, Account $account, Counts $counts, UserAttributes $userAttributes, bool $sensitive, Application $application, array $mentions, array $tags, Card $card, array $attachments, array $reblog) { $this->id = (string)$item['uri-id']; - $this->created_at = DateTimeFormat::utc($item['created'], DateTimeFormat::ATOM); + $this->created_at = DateTimeFormat::utc($item['created'], DateTimeFormat::API); if ($item['gravity'] == GRAVITY_COMMENT) { $this->in_reply_to_id = (string)$item['thr-parent-id']; diff --git a/src/Object/Api/Mastodon/Token.php b/src/Object/Api/Mastodon/Token.php index 1c78d69593..dfd5de0e95 100644 --- a/src/Object/Api/Mastodon/Token.php +++ b/src/Object/Api/Mastodon/Token.php @@ -53,6 +53,6 @@ class Token extends BaseDataTransferObject $this->access_token = $access_token; $this->token_type = $token_type; $this->scope = $scope; - $this->created_at = DateTimeFormat::utc($created_at, DateTimeFormat::ATOM); + $this->created_at = DateTimeFormat::utc($created_at, DateTimeFormat::API); } } diff --git a/src/Util/DateTimeFormat.php b/src/Util/DateTimeFormat.php index eefbfcf7bc..d2a96d0357 100644 --- a/src/Util/DateTimeFormat.php +++ b/src/Util/DateTimeFormat.php @@ -31,9 +31,10 @@ use Exception; */ class DateTimeFormat { - const ATOM = 'Y-m-d\TH:i:s\Z'; + const ATOM = 'Y-m-d\TH:i:s\Z'; const MYSQL = 'Y-m-d H:i:s'; - const HTTP = 'D, d M Y H:i:s \G\M\T'; + const HTTP = 'D, d M Y H:i:s \G\M\T'; + const API = 'Y-m-d\TH:i:s.000\Z'; /** * convert() shorthand for UTC.