mirror of
https://github.com/scorpion-26/gBar.git
synced 2024-11-22 03:02:49 +00:00
Add config for time widget locale (#44)
This makes the `DateTimeStyle` string respect the current locale or whatever valid locale is set via configuration option `DateTimeLocale`. --------- Co-authored-by: Sebastian Zerbe <zerbe@phil.hhu.de>
This commit is contained in:
parent
aee06ab49d
commit
2cc0ec0a66
4 changed files with 6 additions and 0 deletions
|
@ -60,6 +60,9 @@ TimeSpace: 300
|
||||||
# Set datetime style
|
# Set datetime style
|
||||||
# DateTimeStyle: %a %D - %H:%M:%S %Z
|
# DateTimeStyle: %a %D - %H:%M:%S %Z
|
||||||
|
|
||||||
|
# Set datetime locale (defaults to system locale if not set or set to empty string)
|
||||||
|
# DateTimeLocale: de_DE.utf8
|
||||||
|
|
||||||
# Adds a audio input(aka. microphone) widget
|
# Adds a audio input(aka. microphone) widget
|
||||||
AudioInput: false
|
AudioInput: false
|
||||||
|
|
||||||
|
|
|
@ -177,6 +177,7 @@ void Config::Load()
|
||||||
AddConfigVar("BatteryFolder", config.batteryFolder, lineView, foundProperty);
|
AddConfigVar("BatteryFolder", config.batteryFolder, lineView, foundProperty);
|
||||||
AddConfigVar("DefaultWorkspaceSymbol", config.defaultWorkspaceSymbol, lineView, foundProperty);
|
AddConfigVar("DefaultWorkspaceSymbol", config.defaultWorkspaceSymbol, lineView, foundProperty);
|
||||||
AddConfigVar("DateTimeStyle", config.dateTimeStyle, lineView, foundProperty);
|
AddConfigVar("DateTimeStyle", config.dateTimeStyle, lineView, foundProperty);
|
||||||
|
AddConfigVar("DateTimeLocale", config.dateTimeLocale, lineView, foundProperty);
|
||||||
AddConfigVar("CheckPackagesCommand", config.checkPackagesCommand, lineView, foundProperty);
|
AddConfigVar("CheckPackagesCommand", config.checkPackagesCommand, lineView, foundProperty);
|
||||||
for (int i = 1; i < 10; i++)
|
for (int i = 1; i < 10; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,6 +16,7 @@ public:
|
||||||
std::vector<std::string> workspaceSymbols = std::vector<std::string>(9, "");
|
std::vector<std::string> workspaceSymbols = std::vector<std::string>(9, "");
|
||||||
std::string defaultWorkspaceSymbol = "";
|
std::string defaultWorkspaceSymbol = "";
|
||||||
std::string dateTimeStyle = "%a %D - %H:%M:%S %Z"; // A sane default
|
std::string dateTimeStyle = "%a %D - %H:%M:%S %Z"; // A sane default
|
||||||
|
std::string dateTimeLocale = ""; // use system locale
|
||||||
|
|
||||||
// Script that returns how many packages are out-of-date. The script should only print a number!
|
// Script that returns how many packages are out-of-date. The script should only print a number!
|
||||||
// See data/update.sh for a human-readable version
|
// See data/update.sh for a human-readable version
|
||||||
|
|
|
@ -605,6 +605,7 @@ namespace System
|
||||||
time_t stdTime = time(NULL);
|
time_t stdTime = time(NULL);
|
||||||
tm* localTime = localtime(&stdTime);
|
tm* localTime = localtime(&stdTime);
|
||||||
std::stringstream str;
|
std::stringstream str;
|
||||||
|
str.imbue(std::locale(Config::Get().dateTimeLocale.c_str()));
|
||||||
str << std::put_time(localTime, Config::Get().dateTimeStyle.c_str());
|
str << std::put_time(localTime, Config::Get().dateTimeStyle.c_str());
|
||||||
return str.str();
|
return str.str();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue