[Cppcms-users] boost.locale and date formatting
Brought to you by:
artyom-beilis
From: augustin <aug...@ov...> - 2011-05-04 00:27:04
|
(second try to send this to the list) Hello, Speaking of boost(er).locale, I am having problems formatting dates. I tried the simple example from here: http://cppcms.sourceforge.net/boost_locale/html/formatting_and_parsing.html #include <iostream> #include <sstream> #include <boost/locale.hpp> using std::cout; using std::endl; using namespace boost::locale; int main() { double now=time(0); cout << "Today is "<< as::date << now << " and tommorrow is " << now+24*3600 << endl; cout << "Current time is "<< as::time << now << endl; cout << "The current weekday is "<< as::ftime("%A") << now << endl; } g++ main.cpp -o run.main -lboost_locale and the output is: Today is 1.30439e+09 and tommorrow is 1.30448e+09 Current time is 1.30439e+09 The current weekday is 1.30439e+09 I tried with booster.locale that comes with cppcms, and I downloaded from svn and compiled the very latest boost.locale. I get the same result with both. I'm sure I am missing something simple. Probably, I need to set the locale first, but it's not clear to me how to do it. Also, a grip I have with most/all boost libraries, is that one never knows what option to pass to the linker: http://stackoverflow.com/questions/3467153/is-there-an-intelligent-way-to-know- the-name-of-the-library-to-link-to-at-compile Is this platform/compiler dependent? Can't this kind of thing be documented? Anyway, in this case, I found it was -lboost_locale. For boost.locale, more, fully working, compilable examples would help. - Most boost libraries documentation are written for very experienced C++ developers. From a newbie perspective, I find most documentation very obtuse. I checked boost.date_time for a long while, and still couldn't understand enough to actually make use of it. I still have much to learn before I can understand a lot of the boost documentation. - Generally speaking, within the context of a cppcms application, what is the best/recommended way to format dates, times and such? Basically, I have a unix timestamp, and I want to output it in human readable form, both in the UTC and locale timezone. Thanks, 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/ . ------------------------------------------------------- -- 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/ . |