2

What is the correct format to be used for Edm.Time ?

I see in the protocol document the format for DateTime and DateTimeOffset as follows:

Datetime : "yyyy-MM-dd'T'HH:mm:ss.fff" DateTimeoffset : "yyyy-MM-dd'T'HH:mm:ss.fffZ"

I did check the protocol here : http://www.w3.org/TR/xmlschema-2/ but could not get the formatting to be used for Edm.Time. Currently we are using XmlConvert.ToString to convert the time span value to a string representation. Is there any specific representation that OData recommends for Timespan ?

Gert Arnold
  • 105,341
  • 31
  • 202
  • 291
Venki
  • 2,129
  • 6
  • 32
  • 54

1 Answers1

0

The formats should be reasonably well documented here, which points you to this link (in the case of Edm.Time).

From XML Schema 2:

3.2.8.1 Lexical representation

The lexical representation for time is the left truncated lexical representation for dateTime: hh:mm:ss.sss with optional following time zone indicator. For example, to indicate 1:20 pm for Eastern Standard Time which is 5 hours behind Coordinated Universal Time (UTC), one would write: 13:20:00-05:00. See also ISO 8601 Date and Time Formats (§D).

Note that time-and-date-land have had their issues over the years. The date format varies based upon payload format and version. For instance, JSON Verbose used the /Date(...)/ format for OData v2, but changed to ISO 8601 in OData v3 (much to the collective relief of anyone who doesn't have to implement an OData server and care about all these nuances). This is similar to the struggles that the ASP.NET stack has gone through: http://www.hanselman.com/blog/OnTheNightmareThatIsJSONDatesPlusJSONNETAndASPNETWebAPI.aspx.

Mark Stafford - MSFT
  • 4,306
  • 3
  • 17
  • 23
  • 1
    The time format is limited to a single 24hr period (00:00:00 through 23:59:59). How would you represent a TimeSpan that covered several days, weeks or years? 3:00:00:00 is the text representation of a timespan of 3 days. – Simon Gillbee Apr 11 '13 at 18:22