From 015bb675d6eb177900c8ac94a6d35edc5ad90576 Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Wed, 9 May 2018 00:11:35 +0200 Subject: 9.9 --- zen/format_unit.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'zen/format_unit.cpp') diff --git a/zen/format_unit.cpp b/zen/format_unit.cpp index 09134c07..931a29be 100755 --- a/zen/format_unit.cpp +++ b/zen/format_unit.cpp @@ -161,38 +161,39 @@ std::wstring zen::formatFraction(double fraction) -std::wstring zen::impl::includeNumberSeparator(const std::wstring& number) +std::wstring zen::formatNumber(int64_t n) { //we have to include thousands separator ourselves; this doesn't work for all countries (e.g india), but is better than nothing //::setlocale (LC_ALL, ""); -> implicitly called by wxLocale - const lconv* localInfo = ::localeconv(); //always bound according to doc - const std::wstring& thousandSep = zen::utfTo(localInfo->thousands_sep); + const lconv& localInfo = *::localeconv(); //always bound according to doc + const std::wstring& thousandSep = utfTo(localInfo.thousands_sep); // THOUSANDS_SEPARATOR = std::use_facet>(std::locale("")).thousands_sep(); - why not working? // DECIMAL_POINT = std::use_facet>(std::locale("")).decimal_point(); - std::wstring output(number); - size_t i = output.size(); + std::wstring number = numberTo(n); + + size_t i = number.size(); for (;;) { if (i <= 3) break; i -= 3; - if (!isDigit(output[i - 1])) //stop on +, - signs + if (!isDigit(number[i - 1])) //stop on +, - signs break; - output.insert(i, thousandSep); + number.insert(i, thousandSep); } - return output; + return number; } -std::wstring zen::formatUtcToLocalTime(int64_t utcTime) +std::wstring zen::formatUtcToLocalTime(time_t utcTime) { auto errorMsg = [&] { return _("Error") + L" (time_t: " + numberTo(utcTime) + L")"; }; TimeComp loc = getLocalTime(utcTime); - + std::wstring dateString = formatTime(L"%x %X", loc); return !dateString.empty() ? dateString : errorMsg(); } -- cgit