From e70f8d87302d5ec0e0dfd40076a09183c41822fa Mon Sep 17 00:00:00 2001 From: Aleksei Bavshin Date: Wed, 5 Feb 2020 00:51:56 -0800 Subject: [PATCH] fix(clock): lower precision of zoned_time to avoid fractional seconds in output --- include/modules/clock.hpp | 2 +- src/modules/clock.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/modules/clock.hpp b/include/modules/clock.hpp index bb63241d..e3873a6d 100644 --- a/include/modules/clock.hpp +++ b/include/modules/clock.hpp @@ -14,7 +14,7 @@ namespace waybar::modules { struct waybar_time { std::locale locale; - date::zoned_time ztime; + date::zoned_seconds ztime; }; class Clock : public ALabel { diff --git a/src/modules/clock.cpp b/src/modules/clock.cpp index 5655168f..7fa0ad63 100644 --- a/src/modules/clock.cpp +++ b/src/modules/clock.cpp @@ -37,8 +37,9 @@ auto waybar::modules::Clock::update() -> void { // Time zone can change. Be sure to pick that. time_zone_ = date::current_zone(); } - auto now = std::chrono::system_clock::now(); - waybar_time wtime = {locale_, date::make_zoned(time_zone_, now)}; + auto now = std::chrono::system_clock::now(); + waybar_time wtime = {locale_, + date::make_zoned(time_zone_, date::floor(now))}; auto text = fmt::format(format_, wtime); label_.set_markup(text);