Re: [Cppcms-users] C++ locale and boost.locale
Brought to you by:
artyom-beilis
From: augustin <aug...@ov...> - 2011-05-04 15:32:48
|
On Wednesday 04 May 2011 09:29:39 pm Artyom wrote: > http://www.boost.org/doc/libs/1_46_1/more/getting_started/unix- variants.html > http://www.boost.org/doc/libs/1_46_1/more/getting_started/windows.html Ha! Even by reading the official boost documentation page about linking, I wouldn't have guessed what linker option to chose. For Linux/g++, at least, it wouldn't hurt mentioning the -lboost_locale in the docs. > Was too damn busy, I'll try to get to it this week. > Drop me a mail if I forget once again. There's no actual hurry as far as I am concerned, but something just came up today and I may have to travel to Europe for two weeks later this month, so I won't be available then, if I do go. BTW, thanks to your help, I got the missing piece, so that I finally managed to do what I wanted to do: #include <sstream> #include <boost/locale.hpp> std::string timestamp_to_string(time_t const& tt) { using namespace boost::locale; generator gen; std::locale::global(gen("en_US.UTF-8")); std::stringstream ss; ss.imbue(std::locale()); ss << as::date << tt << " "; ss << as::time << tt << std::endl; std::string r = ""; getline(ss, r); return r; } It took me 10-20 hours to research, read and understand enough to come up with the seemingly simple piece of code above. :-/ I use it to format unix timestamps before pushing it to my cppcms::base_content object. I don't know if it's the right approach, but it works... Augustin. -- Friends: http://www.reuniting.info/ My projects: http://astralcity.org/ http://3enjeux.overshoot.tv/ http://linux.overshoot.tv/ http://overshoot.tv/ http://charityware.info/ http://masquilier.org/ http://openteacher.info/ http://minguo.info/ http://www.wechange.org/ http://searching911.info/ . |