Boost logo

Boost Users :

Subject: [Boost-users] date_time formatting issues
From: ariasgore_at_[hidden]
Date: 2009-09-01 05:05:40


Hi,
I have been trying to format a simple posix date time for string representation.

The basic part is plain and simple:
----------------------------------------------
#include <boost/date_time/posix_time/posix_time.hpp>
namespace ps = boost::posix_time;
ps::ptime t(ps::second_clock::local_time());
std::string foo = ps::to_simple_string(t);
----------------------------------------------

But how can I format this returned string? I think the facets are required but as mentioned here : http://www.boost.org/doc/libs/1_40_0/doc/html/date_time/date_time_io.html#date_time.time_facet
I tried something with the boost::date_time::date_input_facet:
e.g
----------------------------------------------
ps::date_input_facet("%A");
ps::ptime t(ps::second_clock::local_time());
std::string foo = ps::to_simple_string(t);
----------------------------------------------

by using it before the simple_string call. I am sure this is wrong but I wouldn't like to use streams in addition to that to simply rearange some parts of a date for that reason.

thanks
sam

-- 
Jetzt kostenlos herunterladen: Internet Explorer 8 und Mozilla Firefox 3 -
sicherer, schneller und einfacher! http://portal.gmx.net/de/go/chbrowser

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