views:

40

answers:

1

I'm beginning a new project which involves heavy xml and schema use accross multiple platforms (windows, windows mobile, Iphone, Ipad, and more which are yet to be discovered!). This xml platform has to be able to exchange date times from all over the world as our product is currently being implemented in Australia as well as in Canada and USA.

Date times are generally the one "type" that causes the most issues between different platforms and languages.

Should I trust the built in date type? or should I break down each date into it's subsections, e.g. elements or attributes for hours, mins, seconds, day, month, year, timezone etc.

I'd like to understand the pro's and con's of each options above.

EDIT: Added 2 follow up questions to get more clarity

  1. if using the plain xml date "type" how do I ensure that all clients are correctly writing the date in this format?

  2. I know that .net I can use DateTime.ToUniversalTime() do other languages have the equivalent, or is it the XML writing dll's that control the conversion to international time?

Thanks Pete

+1  A: 

The "built in" date types in XML schema are an International standard. I can't imagine how you could do better than that on your own.


From XML Schema: The W3C's Object-Oriented Descriptions for XML by Eric van der Vlist, Chapter 16, "Datatype Reference Guide", "xs:dateTime":

Description

This datatype describes instants(sic) identified by the combination of a date and a time. Its value space is described as a "combination of date and time of day" in Chapter 5.4 of ISO 8601. Its lexical space is the extended format "[-]CCYY-MM-DDThh:mm:ss[Z|(+|-)hh:mm]". The timezone may be specified as "Z" (UTC) or "(+|-)hh:mm." Timezones that are not specified are considered "undetermined."

Example

Valid values for xs:dateTime include: "2001-10-26T21:32:52", "2001-10-26T21:32:52+02:00", "2001-10-26T19:32:52Z", "2001-10-26T19:32:52+00:00", "-2001-10-26T21:32:52", or "2001-10-26T21:32:52.12679".

The following values would be invalid: "2001-10-26" (all the parts must be specified), "2001-10-26T21:32" (all the parts must be specified), "2001-10-26T25:32:52+02:00" (the hours part (25) is out of range), or "01-10-26T21:32" (all the parts must be specified).


Note that you can require that a timezone be specified by restricting the value with a pattern restriction.

John Saunders
Thanks John I've added some follow up questions to get more clarity from the answers.
Peter
Thanks once again for the update to your answer John.
Peter