Re: [Cppcms-users] date_time and as::time_zone question
Brought to you by:
artyom-beilis
|
From: Heiko W. <he...@we...> - 2011-03-21 14:25:46
|
Hi Pavel, nice. That works fine. Thanks.
Am 18.03.2011 um 19:35 schrieb Pavel Kropitz:
> hi,
>
> it's locale problem. set std::locale::global() for newly created streams and use imbue() to affect std::cout.
>
> int main() {
> std::locale::global( booster::locale::generator().generate( "" ) );
>
> std::string tz = "Canada/Eastern";
> booster::locale::date_time dt;
>
> std::istringstream is("1999-04-22 12:13:14");
> is >> booster::locale::as::ftime( "%Y-%m-%d %H:%M:%S" ) >> dt;
>
> std::cout.imbue( std::locale() );
>
> std::cout << booster::locale::as::time_zone(tz) << booster::locale::as::ftime( "%Y-%m-%d %H:%M:%S" ) << dt << std::endl;
> }
>
> pavel.
>
>
> On Friday 18 March 2011, Heiko Weber wrote:
> > Hi Artyom,
> >
> > first, thanks for the work, I am really impressed about what I've
> > discovered so far !
> >
> > I am just trying to figure out what parts of "boost" are still accessable
> > with booster ... so, maybe the following is just not working by intention?
> > I hope you can give me some enlightment ;)
> >
> > This one results in an exception:
> >
> > terminate called after throwing an instance of 'std::bad_cast'
> > what(): std::bad_cast
> > Abort trap
> >
> > ---
> >
> > #include <booster/locale/date_time.h>
> > #include <booster/locale/formatting.h>
> > #include <booster/locale/generator.h>
> > #include <booster/locale/localization_backend.h>
> > #include <iostream>
> > #include <sstream>
> >
> > int main() {
> >
> > booster::locale::localization_backend_manager my =
> > booster::locale::localization_backend_manager::global(); // Get global
> > backend
> >
> > my.select("icu");
> >
> > std::string tz = "Canada/Eastern";
> > booster::locale::date_time dt;
> >
> > std::istringstream is("1999-04-22 12:13:14");
> > is >> booster::locale::as::ftime( "%Y-%m-%d %H:%M:%S" ) >> dt;
> > std::cout << booster::locale::as::time_zone(tz) <<
> > booster::locale::as::ftime( "%Y-%m-%d %H:%M:%S" ) << dt << std::endl; }
> >
> > I also also tried it without the backend select, but same result. The throw
> > happens at the constructor of dt, shouldn't it work without setting up a
> > calendar/locale first ?
> >
> > Thanks in advance.
> > Heiko
>
> ------------------------------------------------------------------------------
> Colocation vs. Managed Hosting
> A question and answer guide to determining the best fit
> for your organization - today and in the future.
> http://p.sf.net/sfu/internap-sfd2d_______________________________________________
> Cppcms-users mailing list
> Cpp...@li...
> https://lists.sourceforge.net/lists/listinfo/cppcms-users
--
Wecos <> Heiko Weber Computer Systeme
D-21644 Sauensiek <> Immenweg 5
he...@we... <> http://www.wecos.de
Tel. +49 (4169) 91000 <> Fax +49 (4169) 919033
_______________________________________________________________
This email may contain confidential and privileged material for
the sole use of the intended recipient. Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient please contact the sender and delete all copies.
_______________________________________________________________
Diese E-Mail kann digital signiert sein. Falls Ihr E-Mail-Programm
nicht ueber die notwendigen Prueffunktionen verfuegt, ignorieren
Sie bitte die angehaengte Signatur-Datei.
_______________________________________________________________
This email may be digitally signed. If your email software does
not support the necessary validation feature, please disregard the
attached signature file.
_______________________________________________________________
|