[xsd-users] Re: Datetime

Boris Kolpackov boris at codesynthesis.com
Fri Aug 28 13:21:02 EDT 2009


Hi,

ss ak <ssak22 at gmail.com> writes:

> I have a datetime as string..Thu Aug 27 15:42:20 2009
> would like assign to one of the variable generated as XSD:DataTime.
> 
> Is there any way to this...or we have to parse the string and allocate it
> DateTime dt(11,11,11,11,11,11);

With the default mapping of the dateTime type you will have to parse
the string and initialize the instance with individual parts. If all
you need is to support this particular format in a few places in your
application, then implementing a function that converts it to 
xml_schema::date_time is probably the simplest approach.

Alternatively, you can provide a custom mapping for this type and base
it, for example, on the date_time class from Boost which appears to
support all kinds of text representations of date/time. There is the
'calendar' example in the examples/cxx/tree/custom/ directory which
shows how to do this for the date type. 

Boris




More information about the xsd-users mailing list