Date Time I/O formatting question
I've found the Date Time library incredibly useful for dealing with timestamps, but I can't seem to get the output formatted the way I want. I've followed the example for the Date Time IO Tutorial (http://www.boost.org/doc/libs/1_39_0/doc/html/date_time/date_time_io.html#da...) but the output always comes out the same way. I've tried the following code with Visual Studio Express 2008 and g++ 4.2 on Solaris 10. I'm using Boost 1.39.0. Any help appreciated.
matthew
#include <fstream>
#include <functional>
#include <iostream>
#include <sstream>
#include "boost/date_time/gregorian/gregorian.hpp"
#include "boost/date_time/posix_time/posix_time.hpp"
#include "boost/date_time/local_time/local_time.hpp"
using namespace std;
int main(int argc, char** argv)
{
stringstream ss;
ifstream in( argv[1] );
string inputFormat = argv[2];
string outputFormat = argv[3]; //I want my own formatting.
boost::local_time::local_time_facet* output_facet =
new boost::local_time::local_time_facet();
boost::local_time::local_time_input_facet* input_facet =
new boost::local_time::local_time_input_facet();
ss.imbue(locale(locale::classic(), output_facet));
ss.imbue(locale(ss.getloc(), input_facet));
output_facet->format( outputFormat.c_str() );
input_facet->format( inputFormat.c_str() );
while ( !in.eof() )
{
string s;
getline( in, s );
ss<>p; //This works fine.
string s1 = boost::posix_time::to_simple_string(p);
cout<
"Polder, Matthew J"
participants (2)
-
Commander Pirx
-
Polder, Matthew J