Skip to content

Commit

Permalink
Add timezone config to clock module
Browse files Browse the repository at this point in the history
  • Loading branch information
spk committed May 8, 2019
1 parent fd9b34a commit 0242366
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions resources/config
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"spacing": 10
},
"clock": {
// "timezone": "Europe/Paris",
"tooltip-format": "{:%Y-%m-%d | %H:%M}",
"format-alt": "{:%Y-%m-%d}"
},
Expand Down
6 changes: 6 additions & 0 deletions src/modules/clock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config)
}

auto waybar::modules::Clock::update() -> void {
if (config_["timezone"].isString()) {
std::string tz("TZ=");
tz.append(config_["timezone"].asString());
putenv((char*)tz.c_str());
tzset();
}
auto localtime = fmt::localtime(std::time(nullptr));
auto text = fmt::format(format_, localtime);
label_.set_markup(text);
Expand Down

0 comments on commit 0242366

Please sign in to comment.