Re: [Cppcms-users] booster::date_time parsing
Brought to you by:
artyom-beilis
From: Pavel K. <un...@fu...> - 2011-03-16 23:33:05
|
On Wednesday 16 March 2011, Artyom wrote: > http://cppcms.sourceforge.net/boost_locale/html/using_localization_backends > .html > > >std::string tz = "Europe/Prague"; > > Note you can use this: > > http://cppcms.sourceforge.net/boost_locale/html/namespaceboost_1_1locale_1_ > 1time__zone.html > To set global time zone. > Also you can set timezone independently on stream using as::time_zone > manipulator. yes, they are very usefull. generally, i'm trying to write an example for generating current server timestamp, generating time from user input and storing it as a number (to DB) & restore it to timezone specific date & show it to user. maybe it will be usefull to have this in documentation (with best practise how to set it up with cppcms response()). i missed "as::time_zone" and ">>" parsing possibility for the first time while going through documentation. > It seems that you need to update the ICU version. > I've tested this code (actually boost not booster, but it is the same): > #include <boost/locale.hpp> > #include <iostream> > int main() > { > std::locale::global(boost::locale::generator().generate("")); > std::stringstream s; > time_t d; > s.str("1955-07-21 07:21:07"); > s >> boost::locale::as::ftime("%Y-%m-%d %H:%M:%S") >> d; > std::cout.imbue(std::locale()); > std::cout << s.str() << std::endl; > std::cout << boost::locale::as::ftime("%Y-%m-%d %H:%M:%S") << d << > std::endl; > } > > It hadn't work for icu 3.8 (gave a year 1970) but works without problems > for icu-4.4 and 4.6, > So it seems like ICU issue. (They have bugs as well :-( ) > > It is fairly simple to compile latest ICU version. i work with icu-4.6 (gentoo package), and now tried it with 4.4.2, but without success. anyway, your example works as expected, so i figure out that s >> boost::locale::as::ftime("%Y-%m-%d %H:%M:%S") >> _time_t_ versus s >> boost::locale::as::ftime("%Y-%m-%d %H:%M:%S") >> _date_time_ is the problem. thank you :). |