|
Boost Users : |
Subject: [Boost-users] How to use %e for the format of time_input_facet?
From: xiada74_at_[hidden]
Date: 2010-09-05 09:10:16
I tried the below code:
#include <boost/date_time.hpp>
#include <boost/date_time/posix_time/ptime.hpp>
#include <iostream>
using namespace boost::posix_time;
int main()
{
std::string _format1 = "%Y-%m-%d %H:%M:%S";
std::string _format2 = "%Y-%m-%e %H:%M:%S";
std::string teststring = "2010-09-10 10:01:01";
ptime time1, time2;
time_input_facet facet1(_format1, 1);
time_input_facet facet2(_format2, 1);
std::stringstream ss1(teststring);
std::stringstream ss2(teststring);
ss1.imbue(std::locale(ss1.getloc(), &facet1));
ss1 >> time1;
ss2.imbue(std::locale(ss2.getloc(), &facet2));
ss2 >> time2;
std::cout << "Time1: " << time1 << std::endl;
std::cout << "Time2: " << time2 << std::endl;
return 0;
}
The output is:
Time1: 2010-Sep-10 10:01:01
Time2: not-a-date-time
Who can help to fix the issue for the format using "%e"?
Thanks in advance!
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net