Boost logo

Boost Users :

Subject: [Boost-users] boost::date_time: date & time in RFC 3339 format
From: Stuart (stuart8763_at_[hidden])
Date: 2010-12-17 13:17:58


Hello

I'm trying to use boost::date_time to format the date and time (with
fractional seconds) in RFC3339 format http://tools.ietf.org/html/rfc3339.
I'd like my date to look like "1996-12-19T16:39:57.76-08:00".

date +'%FT%T.%N%:z' gives me the format that I want

2010-12-17T17:09:41.079937078+01:00

The boost/C++ code at the end of this message gives me

2010-12-17T16:10:03.141889Z

this is the correct time but I want the time in my time zone with an
indication of the time zone (+0100) not in UTC with a "Z".

Can anyone give me a hint?

Another question, is there anyway to control the number of decimals
after the point for the seconds?

thanks
Stuart

#include <boost/date_time.hpp>

std::cout.imbue(std::locale(std::cout.getloc(), new boost::local_time::local_time_facet("%Y-%m-%dT%H:%M:%S%F%Q")));
std::cout << boost::local_time::local_microsec_clock::local_time(boost::local_time::time_zone_ptr()) << std::endl;


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