diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-04-28 17:41:58 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-04-28 17:42:02 +0200 |
commit | 7d0d8a1bf0ffbaf073303efc7d7bfc58177277a6 (patch) | |
tree | bad9198e5800d4569a0941d3648723da4cbf263e /src/QuickMedia.cpp | |
parent | 1b7abc7e819d055b3d0ea5be8967a1e381bb5d60 (diff) |
Calculate subscription uploaded time difference correctly when taking timezone into consideration
Diffstat (limited to 'src/QuickMedia.cpp')
-rw-r--r-- | src/QuickMedia.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 456bdc6..54308a4 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -1019,7 +1019,9 @@ namespace QuickMedia { }; // Returns relative time as a string (approximation) - static std::string timestamp_to_relative_time_str(time_t seconds) { + static std::string seconds_to_relative_time_str(time_t seconds) { + seconds = std::max(0L, seconds); + time_t minutes = seconds / 60; time_t hours = minutes / 60; time_t days = hours / 24; @@ -1068,7 +1070,7 @@ namespace QuickMedia { auto body_item = BodyItem::create(std::move(title_str)); body_item->url = "https://www.youtube.com/watch?v=" + video_id_str; body_item->thumbnail_url = "https://img.youtube.com/vi/" + video_id_str + "/hqdefault.jpg"; - body_item->set_description("Watched " + timestamp_to_relative_time_str(std::max(0l, time_now - timestamp.asInt64()))); + body_item->set_description("Watched " + seconds_to_relative_time_str(time_now - timestamp.asInt64())); body_item->thumbnail_size = sf::Vector2i(175, 131); body_items.push_back(std::move(body_item)); } |