Thread: [Cppcms-users] strange date time parsing
Brought to you by:
artyom-beilis
From: <ele...@ex...> - 2012-07-09 06:17:17
|
Hi, Can someone please explain this? int main() { booster::locale::generator gen; std::locale::global(gen("")); std::istringstream is("01_01_2012-05_30_45"); booster::locale::date_time dt; is >> booster::locale::as::ftime("%d_%m_%Y-%H_%M_%S") >> dt; std::ostringstream os; os << dt; std::cout << os.str() << std::endl; return 0; } The output is: Dec 25, 2011 5:30:45 AM |
From: <ele...@ex...> - 2012-07-09 06:28:21
|
> booster::locale::generator gen; > std::locale::global(gen("")); > > std::istringstream is("01_01_2012-05_30_45"); > booster::locale::date_time dt; > is >> booster::locale::as::ftime("%d_%m_%Y-%H_%M_%S") >> dt; it seems like that if i move %Y and the year to start like this: std::istringstream is("2012-01_01-05_30_45"); booster::locale::date_time dt; is >> booster::locale::as::ftime("%Y_%d_%m-%H_%M_%S") >> dt; Then it works. Is there something im doing wrong? |
From: Lee E. <lee...@gm...> - 2012-07-09 07:28:33
|
it seems the the format of the date and for the parsing do not match in the second example On Mon, Jul 9, 2012 at 9:28 AM, <ele...@ex...> wrote: > > booster::locale::generator gen; > > std::locale::global(gen("")); > > > > std::istringstream is("01_01_2012-05_30_45"); > > booster::locale::date_time dt; > > is >> booster::locale::as::ftime("%d_%m_%Y-%H_%M_%S") >> dt; > > > it seems like that if i move %Y and the year to start like this: > > std::istringstream is("2012-01_01-05_30_45"); > booster::locale::date_time dt; > is >> booster::locale::as::ftime("%Y_%d_%m-%H_%M_%S") >> dt; > > Then it works. > > Is there something im doing wrong? > > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > -- -- lee Lee Elenbaas lee...@gm... |
From: <ele...@ex...> - 2012-07-09 07:35:59
|
> it seems the the format of the date and for the parsing do not match in > the > second example > Sorry that was just a typo. see, I fixed it below > it seems like that if i move %Y and the year to start like this: > > std::istringstream is("2012_01_01-05_30_45"); > booster::locale::date_time dt; > is >> booster::locale::as::ftime("%Y_%d_%m-%H_%M_%S") >> dt; The problem is still the same. It seems like the time gets parsed properly everytime but the date does not unless the date is in the format %Y_%d_%m or %Y_%m-%d Petr |
From: Artyom B. <art...@ya...> - 2012-07-12 08:17:04
|
See, time parsing is done by ICU library. If it fails to parse such a date, it seems to be ICU limitation. Also make sure that correct locale installed into std::istringstream is; (If it is set globally should not be a problem) Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ >________________________________ > From: "ele...@ex..." <ele...@ex...> >To: Lee Elenbaas <lee...@gm...> >Cc: cpp...@li... >Sent: Monday, July 9, 2012 10:35 AM >Subject: Re: [Cppcms-users] strange date time parsing > >> it seems the the format of the date and for the parsing do not match in >> the >> second example >> > >Sorry that was just a typo. > >see, I fixed it below > >> it seems like that if i move %Y and the year to start like this: >> >> std::istringstream is("2012_01_01-05_30_45"); >> booster::locale::date_time dt; >> is >> booster::locale::as::ftime("%Y_%d_%m-%H_%M_%S") >> dt; > > >The problem is still the same. It seems like the time gets parsed properly >everytime but the date does not unless the date is in the format %Y_%d_%m >or %Y_%m-%d > >Petr > > >------------------------------------------------------------------------------ >Live Security Virtual Conference >Exclusive live event will cover all the ways today's security and >threat landscape has changed and how IT managers can respond. Discussions >will include endpoint security, mobile security and the latest in malware >threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ >_______________________________________________ >Cppcms-users mailing list >Cpp...@li... >https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > |