Getting a xsd:datetime from boost::date_time

Hi, (sorry if this is off topic) I need to get the current date and time and convert it into a string that follows the xsd:datetime time stamp format: [-]CCYY-MM-DDThh:mm:ss[Z|(+|-)hh:mm]. (timezone should be UTC) Any ideas on how to do that? The Boost::Date_Time library documentation is confusing to my feeble mind. Thanks, Joe

On Mon, 31 Jul 2006 16:49:01 -0700, "Joe Van Dyk" <joevandyk@gmail.com> wrote:
Hi,
(sorry if this is off topic)
Basically it is, but everything can be made on-topic if adequately worded :-)
I need to get the current date and time and convert it into a string that follows the xsd:datetime time stamp format: [-]CCYY-MM-DDThh:mm:ss[Z|(+|-)hh:mm].
(timezone should be UTC)
Any ideas on how to do that? The Boost::Date_Time library documentation is confusing to my feeble mind.
If that's your only usage then date_time is probably overkill and I'd suggest just resorting to the standard strftime. Something like this might fit your needs: <http://boost.cvs.sourceforge.net/boost/boost/tools/common/time_string.hpp?revision=1.1&view=markup> -- [ Gennaro Prota, C++ developer for hire ]

On 8/1/06, Gennaro Prota <gennaro_prota@yahoo.com> wrote:
On Mon, 31 Jul 2006 16:49:01 -0700, "Joe Van Dyk" <joevandyk@gmail.com> wrote:
Hi,
(sorry if this is off topic)
Basically it is, but everything can be made on-topic if adequately worded :-)
I need to get the current date and time and convert it into a string that follows the xsd:datetime time stamp format: [-]CCYY-MM-DDThh:mm:ss[Z|(+|-)hh:mm].
(timezone should be UTC)
Any ideas on how to do that? The Boost::Date_Time library documentation is confusing to my feeble mind.
If that's your only usage then date_time is probably overkill and I'd suggest just resorting to the standard strftime. Something like this might fit your needs:
<http://boost.cvs.sourceforge.net/boost/boost/tools/common/time_string.hpp?revision=1.1&view=markup>
Actually, boost::posix_time::ptime::to_iso_extended_string worked out nicely. Joe
participants (2)
-
Gennaro Prota
-
Joe Van Dyk