From b526f481204a4c9324daf9d223a270c36b6d4d60 Mon Sep 17 00:00:00 2001 From: RadoslavL Date: Fri, 16 Aug 2024 23:57:49 +0300 Subject: [PATCH] Changed Unix time to Rfc3339 time and removed NaN message --- src/invidious/jsonify/api_v1/video_json.cr | 4 ++-- src/invidious/videos/parser.cr | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/invidious/jsonify/api_v1/video_json.cr b/src/invidious/jsonify/api_v1/video_json.cr index b8fe87c7..8c9a5cd3 100644 --- a/src/invidious/jsonify/api_v1/video_json.cr +++ b/src/invidious/jsonify/api_v1/video_json.cr @@ -247,9 +247,9 @@ module Invidious::JSONify::APIv1 json.field "viewCount", rv["view_count"]?.try &.empty? ? nil : rv["view_count"].to_i64 json.field "published", rv["published"]? if !rv["published"].nil? - json.field "publishedText", translate(locale, "`x` ago", recode_date(Time.unix(rv["published"].to_i), locale)) + json.field "publishedText", translate(locale, "`x` ago", recode_date(Time.parse_rfc3339(rv["published"].to_s), locale)) else - json.field "publishedText", translate(locale, "`x` ago", "NaN") + json.field "publishedText", "" end end end diff --git a/src/invidious/videos/parser.cr b/src/invidious/videos/parser.cr index 73f8bbb0..769e3368 100644 --- a/src/invidious/videos/parser.cr +++ b/src/invidious/videos/parser.cr @@ -38,7 +38,7 @@ def parse_related_video(related : JSON::Any) : Hash(String, JSON::Any)? if published_time_text = related["publishedTimeText"]? decoded_time = decode_date(published_time_text["simpleText"].to_s) - published = decoded_time.to_unix.to_s + published = decoded_time.to_rfc3339.to_s else published = nil end