fix(clock): lower precision of zoned_time to avoid fractional seconds in output

pull/579/head
Aleksei Bavshin 2020-02-05 00:51:56 -08:00
parent e1215a6d17
commit e70f8d8730
No known key found for this signature in database
GPG Key ID: 4F071603387A382A
2 changed files with 4 additions and 3 deletions

View File

@ -14,7 +14,7 @@ namespace waybar::modules {
struct waybar_time { struct waybar_time {
std::locale locale; std::locale locale;
date::zoned_time<std::chrono::system_clock::duration> ztime; date::zoned_seconds ztime;
}; };
class Clock : public ALabel { class Clock : public ALabel {

View File

@ -37,8 +37,9 @@ auto waybar::modules::Clock::update() -> void {
// Time zone can change. Be sure to pick that. // Time zone can change. Be sure to pick that.
time_zone_ = date::current_zone(); time_zone_ = date::current_zone();
} }
auto now = std::chrono::system_clock::now(); auto now = std::chrono::system_clock::now();
waybar_time wtime = {locale_, date::make_zoned(time_zone_, now)}; waybar_time wtime = {locale_,
date::make_zoned(time_zone_, date::floor<std::chrono::seconds>(now))};
auto text = fmt::format(format_, wtime); auto text = fmt::format(format_, wtime);
label_.set_markup(text); label_.set_markup(text);