Here is the code snippet
std::wstring aResult;
boost::locale::generator gen;
std::locale::global(gen(""));
std::wostringstream output;
output.imbue(std::locale());
boost::locale::date_time aTime(x);
output << boost::locale::as::date_short << aTime;
aResult = output.str();
The problem is that the output always give the date format specified by locale and
as::date_short
as::date_long
as::date_middle
always give identical results.
What can be the case here?
Thanks!
It probably indicates your system has no/incomplete locale definitions.
E.g. this program:
#include <boost/locale.hpp>
#include <string>
int main()
{
std::wstring aResult;
boost::locale::generator gen;
std::locale::global(gen("C"));
std::wcout.imbue(std::locale());
boost::locale::date_time aTime;
std::wcout << std::endl << boost::locale::as::date_full << aTime;
std::wcout << std::endl << boost::locale::as::date_short << aTime;
std::wcout << std::endl << boost::locale::as::date_medium << aTime;
}
Prints, on my Ubuntu box:
Thursday, June 5, 2014 3:06:27 PM
6/5/14 3:06:27 PM
Jun 5, 2014 3:06:27 PM
But Live On Coliru (which runs on Debian) the same code prints:
Thu Jun 5 13:07:04 2014
Thu Jun 5 13:07:04 2014
Thu Jun 5 13:07:04 2014