From a268daf59f5b3a8ccd99f2b821a4c7cbcca3ccbc Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 27 Jan 2014 01:25:07 -0600 Subject: remove code duplication between formatter.cpp and utils.cpp --- src/formatter.cpp | 10 ++-------- src/utils.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/formatter.cpp b/src/formatter.cpp index a271ba0..989781a 100644 --- a/src/formatter.cpp +++ b/src/formatter.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -226,14 +227,7 @@ Formatter::~Formatter() bool Formatter::is_locale_12h() { - static const char *formats_24h[] = {"%H", "%R", "%T", "%OH", "%k"}; - const auto t_fmt = nl_langinfo(T_FMT); - - for (const auto& needle : formats_24h) - if (strstr(t_fmt, needle)) - return false; - - return true; + return ::is_locale_12h(); } const char* diff --git a/src/utils.cpp b/src/utils.cpp index 0b586f4..e97b654 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -38,11 +38,11 @@ with this program. If not, see . gboolean is_locale_12h() { - const char *t_fmt = nl_langinfo(T_FMT); - static const char *formats_24h[] = {"%H", "%R", "%T", "%OH", "%k"}; - for(const auto& format : formats_24h) - if(strstr(t_fmt, format) != nullptr) + const auto t_fmt = nl_langinfo(T_FMT); + + for (const auto& needle : formats_24h) + if (strstr(t_fmt, needle) != nullptr) return false; return true; -- cgit v1.2.3