diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr index 246f3967..c186243c 100644 --- a/src/invidious/comments.cr +++ b/src/invidious/comments.cr @@ -6,12 +6,26 @@ class RedditThing end class RedditComment + module TimeConverter + def self.from_json(value : JSON::PullParser) : Time + Time.epoch(value.read_float.to_i) + end + + def self.to_json(value : Time, json : JSON::Builder) + json.number(value.epoch) + end + end + JSON.mapping({ author: String, body_html: String, replies: RedditThing | String, score: Int32, depth: Int32, + created: { + type: Time, + converter: RedditComment::TimeConverter, + }, }) end @@ -144,6 +158,7 @@ def template_reddit_comments(root) [ - ] #{score} #{author} + - #{recode_date(child.created)} ago

#{body_html}