format money correctly

This commit is contained in:
Martin Brodbeck 2018-07-24 07:50:51 +02:00
parent fa7938ca20
commit 669a708bce
1 changed files with 6 additions and 2 deletions

View File

@ -114,8 +114,12 @@ int Marketplace::getBasketSumInCent()
std::string Marketplace::getBasketSumAsString() std::string Marketplace::getBasketSumAsString()
{ {
int sumInCent = getBasketSumInCent(); int sumInCent = getBasketSumInCent();
double sumInEuro = sumInCent / 100.0L; // double sumInEuro = sumInCent / 100.0L;
// std::stringstream sumStream;
// sumStream << std::fixed << std::setprecision(2) << sumInEuro << " €";
// return sumStream.str();
std::stringstream sumStream; std::stringstream sumStream;
sumStream << std::fixed << std::setprecision(2) << sumInEuro << ""; sumStream.imbue(std::locale("de_DE.utf8"));
sumStream << std::right << std::setw(12) << std::showbase << std::put_money(sumInCent, false);
return sumStream.str(); return sumStream.str();
} }