From 4fc2f964b26fc4f9ecd9302bc0cebdcec95bc969 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Tue, 13 Dec 2022 21:55:03 +0100 Subject: [PATCH] Change date parsing from Invidious --- Extensions/Double+Format.swift | 4 +++- Model/Applications/InvidiousAPI.swift | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Extensions/Double+Format.swift b/Extensions/Double+Format.swift index 488c27cb..7b7e0cef 100644 --- a/Extensions/Double+Format.swift +++ b/Extensions/Double+Format.swift @@ -19,7 +19,9 @@ extension Double { let date = Date(timeIntervalSince1970: self) let formatter = RelativeDateTimeFormatter() - formatter.unitsStyle = .full + formatter.dateTimeStyle = .named + formatter.unitsStyle = .short + formatter.formattingContext = .standalone return formatter.localizedString(for: date, relativeTo: Date()) } diff --git a/Model/Applications/InvidiousAPI.swift b/Model/Applications/InvidiousAPI.swift index c01b2132..4f83f35d 100644 --- a/Model/Applications/InvidiousAPI.swift +++ b/Model/Applications/InvidiousAPI.swift @@ -460,10 +460,12 @@ final class InvidiousAPI: Service, ObservableObject, VideosAPI { func extractVideo(from json: JSON) -> Video { let indexID: String? var id: Video.ID + var published = json["publishedText"].stringValue var publishedAt: Date? if let publishedInterval = json["published"].double { publishedAt = Date(timeIntervalSince1970: publishedInterval) + published = "" } let videoID = json["videoId"].stringValue @@ -486,7 +488,7 @@ final class InvidiousAPI: Service, ObservableObject, VideosAPI { title: json["title"].stringValue, author: json["author"].stringValue, length: json["lengthSeconds"].doubleValue, - published: json["publishedText"].stringValue, + published: published, views: json["viewCount"].intValue, description: description, genre: json["genre"].stringValue,