Read published date from timestamp directly
This commit is contained in:
parent
6b38c07654
commit
7453e397d5
|
@ -10,7 +10,6 @@
|
||||||
179DB02FFBC17AC9798F0EBC /* NewsBlurStory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 179DB7399814F6FB3247825C /* NewsBlurStory.swift */; };
|
179DB02FFBC17AC9798F0EBC /* NewsBlurStory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 179DB7399814F6FB3247825C /* NewsBlurStory.swift */; };
|
||||||
179DB28CF49F73A945EBF5DB /* NewsBlurLoginResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 179DB088236E3236010462E8 /* NewsBlurLoginResponse.swift */; };
|
179DB28CF49F73A945EBF5DB /* NewsBlurLoginResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 179DB088236E3236010462E8 /* NewsBlurLoginResponse.swift */; };
|
||||||
179DB49A960F8B78C4924458 /* NewsBlurGenericCodingKeys.swift in Sources */ = {isa = PBXBuildFile; fileRef = 179DB66D933E976C29159DEE /* NewsBlurGenericCodingKeys.swift */; };
|
179DB49A960F8B78C4924458 /* NewsBlurGenericCodingKeys.swift in Sources */ = {isa = PBXBuildFile; fileRef = 179DB66D933E976C29159DEE /* NewsBlurGenericCodingKeys.swift */; };
|
||||||
179DB61D33CD8DC94C90F7ED /* NewsBlurDate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 179DBB17C42E6E434EDC29FA /* NewsBlurDate.swift */; };
|
|
||||||
179DBED55C9B4D6A413486C1 /* NewsBlurUnreadStory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 179DB818180A51098A9816B2 /* NewsBlurUnreadStory.swift */; };
|
179DBED55C9B4D6A413486C1 /* NewsBlurUnreadStory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 179DB818180A51098A9816B2 /* NewsBlurUnreadStory.swift */; };
|
||||||
179DBF4DE2562D4C532F6008 /* NewsBlurFeed.swift in Sources */ = {isa = PBXBuildFile; fileRef = 179DB1B909672E0E807B5E8C /* NewsBlurFeed.swift */; };
|
179DBF4DE2562D4C532F6008 /* NewsBlurFeed.swift in Sources */ = {isa = PBXBuildFile; fileRef = 179DB1B909672E0E807B5E8C /* NewsBlurFeed.swift */; };
|
||||||
3B3A33E7238D3D6800314204 /* Secrets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3B3A33E6238D3D6800314204 /* Secrets.swift */; };
|
3B3A33E7238D3D6800314204 /* Secrets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3B3A33E6238D3D6800314204 /* Secrets.swift */; };
|
||||||
|
@ -233,7 +232,6 @@
|
||||||
179DB66D933E976C29159DEE /* NewsBlurGenericCodingKeys.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NewsBlurGenericCodingKeys.swift; sourceTree = "<group>"; };
|
179DB66D933E976C29159DEE /* NewsBlurGenericCodingKeys.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NewsBlurGenericCodingKeys.swift; sourceTree = "<group>"; };
|
||||||
179DB7399814F6FB3247825C /* NewsBlurStory.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NewsBlurStory.swift; sourceTree = "<group>"; };
|
179DB7399814F6FB3247825C /* NewsBlurStory.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NewsBlurStory.swift; sourceTree = "<group>"; };
|
||||||
179DB818180A51098A9816B2 /* NewsBlurUnreadStory.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NewsBlurUnreadStory.swift; sourceTree = "<group>"; };
|
179DB818180A51098A9816B2 /* NewsBlurUnreadStory.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NewsBlurUnreadStory.swift; sourceTree = "<group>"; };
|
||||||
179DBB17C42E6E434EDC29FA /* NewsBlurDate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NewsBlurDate.swift; sourceTree = "<group>"; };
|
|
||||||
3B3A33E6238D3D6800314204 /* Secrets.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Secrets.swift; path = ../../Shared/Secrets.swift; sourceTree = "<group>"; };
|
3B3A33E6238D3D6800314204 /* Secrets.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Secrets.swift; path = ../../Shared/Secrets.swift; sourceTree = "<group>"; };
|
||||||
3B826D9E2385C81C00FC1ADB /* FeedWranglerAuthorizationResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedWranglerAuthorizationResult.swift; sourceTree = "<group>"; };
|
3B826D9E2385C81C00FC1ADB /* FeedWranglerAuthorizationResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedWranglerAuthorizationResult.swift; sourceTree = "<group>"; };
|
||||||
3B826D9F2385C81C00FC1ADB /* FeedWranglerFeedItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedWranglerFeedItem.swift; sourceTree = "<group>"; };
|
3B826D9F2385C81C00FC1ADB /* FeedWranglerFeedItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedWranglerFeedItem.swift; sourceTree = "<group>"; };
|
||||||
|
@ -459,7 +457,6 @@
|
||||||
179DB7399814F6FB3247825C /* NewsBlurStory.swift */,
|
179DB7399814F6FB3247825C /* NewsBlurStory.swift */,
|
||||||
179DB66D933E976C29159DEE /* NewsBlurGenericCodingKeys.swift */,
|
179DB66D933E976C29159DEE /* NewsBlurGenericCodingKeys.swift */,
|
||||||
179DB818180A51098A9816B2 /* NewsBlurUnreadStory.swift */,
|
179DB818180A51098A9816B2 /* NewsBlurUnreadStory.swift */,
|
||||||
179DBB17C42E6E434EDC29FA /* NewsBlurDate.swift */,
|
|
||||||
);
|
);
|
||||||
path = Models;
|
path = Models;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@ -1154,7 +1151,6 @@
|
||||||
179DB02FFBC17AC9798F0EBC /* NewsBlurStory.swift in Sources */,
|
179DB02FFBC17AC9798F0EBC /* NewsBlurStory.swift in Sources */,
|
||||||
179DB49A960F8B78C4924458 /* NewsBlurGenericCodingKeys.swift in Sources */,
|
179DB49A960F8B78C4924458 /* NewsBlurGenericCodingKeys.swift in Sources */,
|
||||||
179DBED55C9B4D6A413486C1 /* NewsBlurUnreadStory.swift in Sources */,
|
179DBED55C9B4D6A413486C1 /* NewsBlurUnreadStory.swift in Sources */,
|
||||||
179DB61D33CD8DC94C90F7ED /* NewsBlurDate.swift in Sources */,
|
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
//
|
|
||||||
// NewsBlurDate.swift
|
|
||||||
// Account
|
|
||||||
//
|
|
||||||
// Created by Anh Quang Do on 2020-03-13.
|
|
||||||
// Copyright (c) 2020 Ranchero Software, LLC. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
import Foundation
|
|
||||||
|
|
||||||
struct NewsBlurDate {
|
|
||||||
static let yyyyMMddHHmmss: DateFormatter = {
|
|
||||||
let formatter = DateFormatter()
|
|
||||||
formatter.calendar = Calendar(identifier: .iso8601)
|
|
||||||
formatter.locale = Locale(identifier: "en_US_POSIX")
|
|
||||||
formatter.timeZone = TimeZone(abbreviation: "GMT")
|
|
||||||
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
|
|
||||||
return formatter
|
|
||||||
}()
|
|
||||||
}
|
|
|
@ -22,7 +22,12 @@ struct NewsBlurStoriesResponse: Decodable {
|
||||||
let url: String?
|
let url: String?
|
||||||
let authorName: String?
|
let authorName: String?
|
||||||
let contentHTML: String?
|
let contentHTML: String?
|
||||||
let datePublished: Date
|
var datePublished: Date? {
|
||||||
|
let interval = (publishedTimestamp as NSString).doubleValue
|
||||||
|
return Date(timeIntervalSince1970: interval)
|
||||||
|
}
|
||||||
|
|
||||||
|
private var publishedTimestamp: String
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +45,6 @@ extension NewsBlurStoriesResponse.Story {
|
||||||
case url = "story_permalink"
|
case url = "story_permalink"
|
||||||
case authorName = "story_authors"
|
case authorName = "story_authors"
|
||||||
case contentHTML = "story_content"
|
case contentHTML = "story_content"
|
||||||
case datePublished = "story_date"
|
case publishedTimestamp = "story_timestamp"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,7 +143,7 @@ final class NewsBlurAPICaller: NSObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
let request = URLRequest(url: callURL, credentials: credentials)
|
let request = URLRequest(url: callURL, credentials: credentials)
|
||||||
transport.send(request: request, resultType: NewsBlurStoriesResponse.self, dateDecoding: .formatted(NewsBlurDate.yyyyMMddHHmmss)) { result in
|
transport.send(request: request, resultType: NewsBlurStoriesResponse.self) { result in
|
||||||
switch result {
|
switch result {
|
||||||
case .success((_, let payload)):
|
case .success((_, let payload)):
|
||||||
completion(.success(payload?.stories))
|
completion(.success(payload?.stories))
|
||||||
|
|
Loading…
Reference in New Issue