From 18c74a4c88b471021da0be85f8052e4cfd597310 Mon Sep 17 00:00:00 2001 From: Jianxin Gao Date: Sun, 22 Mar 2020 16:32:43 +0800 Subject: [PATCH 1/2] Handle timestamp in microseconds --- SwiftyInsta/Local/Responses/ThreadResponse.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SwiftyInsta/Local/Responses/ThreadResponse.swift b/SwiftyInsta/Local/Responses/ThreadResponse.swift index 861c3b1..15bd0c2 100644 --- a/SwiftyInsta/Local/Responses/ThreadResponse.swift +++ b/SwiftyInsta/Local/Responses/ThreadResponse.swift @@ -57,7 +57,7 @@ public struct Message: ItemIdentifiableParsedResponse, UserIdentifiableParsedRes public var sentAt: Date { return rawResponse.timestamp .double - .flatMap { $0 > 9_999_999_999 ? $0/1_000 : $0 } + .flatMap { $0 > 9_999_999_999_999 ? $0/1_000_000 : ($0 > 9_999_999_999 ? $0/1_000 : $0) } .flatMap { Date(timeIntervalSince1970: $0) } ?? .distantPast } /// The `text` value. From 069b69ae83f1e4d377d45e41d7667a8939e9bee1 Mon Sep 17 00:00:00 2001 From: Jianxin Gao Date: Mon, 23 Mar 2020 09:59:15 +0800 Subject: [PATCH 2/2] Handle timestamp in microseconds --- SwiftyInsta/Local/Responses/ThreadResponse.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SwiftyInsta/Local/Responses/ThreadResponse.swift b/SwiftyInsta/Local/Responses/ThreadResponse.swift index 15bd0c2..d5712b2 100644 --- a/SwiftyInsta/Local/Responses/ThreadResponse.swift +++ b/SwiftyInsta/Local/Responses/ThreadResponse.swift @@ -57,7 +57,7 @@ public struct Message: ItemIdentifiableParsedResponse, UserIdentifiableParsedRes public var sentAt: Date { return rawResponse.timestamp .double - .flatMap { $0 > 9_999_999_999_999 ? $0/1_000_000 : ($0 > 9_999_999_999 ? $0/1_000 : $0) } + .flatMap { $0 / pow(10.0, max(floor(log10($0)) - 9, 0)) } .flatMap { Date(timeIntervalSince1970: $0) } ?? .distantPast } /// The `text` value.