
#include <boost/locale.hpp>
#include <iostream> //#include <ctime>
using namespace boost::locale;
int main() { generator gen; //std::locale::global(gen("snthsnth")); // no exception std::locale::global(gen("en_US.UTF-8"));
double now = time(0);
std::cout << "Today is " << as::date << now << std::endl << "Current time is " << as::time << now << std::endl << "The current weekday is " << as::ftime("%A") << now << std::endl;
std::cin.get(); }
http://cppcms.sourceforge.net/boost_locale/html/formatting_and_parsing.html
I get warnings about converting from time_t to double (which I rather expected) and then get basic, double formatted output:
Today is 1.3029e+009 Current time is 1.3029e+009 The current weekday is 1.3029e+009
Changing the global locale does not affect the currently created streams so what you need is to add a line. std::cout.imbue(std::locale()); // Now global locale imbued to stream as well. and then std::cout << as::date << now;
//std::locale::global(gen("snthsnth")); // no exception
It is intentional. If fallbacks to some generic locale if it is not found. It allows you to handle at least messages for non-supported locales (lets say Epseranto) Artyom