From 575a10ec2d4b5e1a6bb3e8def87b6be0d9272cc1 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Sun, 28 Aug 2016 09:11:53 +0200 Subject: fix last modified cropping --- lib/Db/Item.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/Db/Item.php b/lib/Db/Item.php index 1909019c1..a208cc798 100644 --- a/lib/Db/Item.php +++ b/lib/Db/Item.php @@ -150,7 +150,7 @@ class Item extends Entity implements IAPI, \JsonSerializable { 'feedId' => $this->getFeedId(), 'unread' => $this->isUnread(), 'starred' => $this->isStarred(), - 'lastModified' => (int) substr($this->getLastModified(), 0, -6), + 'lastModified' => $this->cropApiLastModified(), 'rtl' => $this->getRtl(), 'fingerprint' => $this->getFingerprint(), 'contentHash' => $this->getContentHash() @@ -252,4 +252,16 @@ class Item extends Entity implements IAPI, \JsonSerializable { )); } + /** + * @return int + */ + public function cropApiLastModified() { + $lastModified = $this->getLastModified(); + if (strlen((string)$lastModified > 10)) { + return (int)substr($lastModified, 0, -6); + } else { + return $lastModified; + } + } + } -- cgit v1.2.3