From 8cd6e1330894c6371e49a61ca0f76f72d016dd88 Mon Sep 17 00:00:00 2001 From: Daniel De Graaf Date: Wed, 5 Aug 2020 20:31:36 -0400 Subject: [PATCH] clock: allow custom formatting for today in calendar --- man/waybar-clock.5.scd | 5 +++++ src/modules/clock.cpp | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/man/waybar-clock.5.scd b/man/waybar-clock.5.scd index 3610f19d..79555bcb 100644 --- a/man/waybar-clock.5.scd +++ b/man/waybar-clock.5.scd @@ -31,6 +31,11 @@ The *clock* module displays the current date and time. default: inferred from current locale ++ A locale to be used to display the time. Intended to render times in custom timezones with the proper language and format. +*today-format*: ++ + typeof: string ++ + default: {} ++ + The format of today's date in the calendar. + *max-length*: ++ typeof: integer ++ The maximum length in character the module should display. diff --git a/src/modules/clock.cpp b/src/modules/clock.cpp index f41126b0..cfdeda2d 100644 --- a/src/modules/clock.cpp +++ b/src/modules/clock.cpp @@ -99,7 +99,12 @@ auto waybar::modules::Clock::calendar_text(const waybar_time& wtime) -> std::str os << '\n'; } if (d == curr_day) { - os << "" << date::format("%e", d) << ""; + if (config_["today-format"].isString()) { + auto today_format = config_["today-format"].asString(); + os << fmt::format(today_format, date::format("%e", d)); + } else { + os << "" << date::format("%e", d) << ""; + } } else { os << date::format("%e", d); }