Problem when parsing DateTimeOffset

Feb 27, 2012 at 2:56 PM

Hi I have the following problem:

I have a datetimeoffset type which is handed over to datajs and datajs crashes in the

parseJsonDateString method where the value parameter of the property is datetimeoffset'2012-02-20T12:40:45.327+01:00'

Then the


method returns null... 


All this happens in the jsonParser and the property type is Edm.DateTimeOffset and the value as seen above:


Is this a bug? 

Thanks and best regards



Feb 28, 2012 at 2:16 AM
Edited Feb 28, 2012 at 8:09 PM

Hi Joe, 

So, the property value you are getting from the endpoint is datetimeoffset'2012-02-20T12:40:45.327+01:00'

The format of the value is odd because per the protcol the library is expecting a value in the form \/Date(<miliseconds> +|- <offset>)\/.  That's why the regular expression fails to match and  returns a null value.  Can you share with us a trace of the request and the response?  Is the endpoint using Microsoft WCF Data Services or some other OData implementation?


Alex Trigo.

Mar 5, 2012 at 3:13 PM
Edited Mar 5, 2012 at 3:13 PM

Hi Alex,

hope you are doing great :).

Thanks for your answer but I don't get it. The spec says:

Literal form of Edm.DateTimeOffset as used in URIs formatted as a JSON string


So should the value now include the string 'datetimeoffset' or not?

And is this different for dates? I see here an example:


So what is the correct value the server should sent for datetime and datetimeoffset?

Thanks for your help!


Mar 5, 2012 at 7:51 PM

Hi Joe,

I'm doing good thank you :). The documentation you mention above can be a little bit confusing. The protocol specificiation document states that DateTimeOffset in JSON should follow the same format as the Date in JSON.

jsonDateTime= quotation-mark 
              [("+" / "-") offset]

ticks       = *DIGIT

; ticks is the number of milliseconds since midnight 
; January 1, 1970

offset      = 4DIGIT
; offset represents the number of minutes to add (if preceded by "+") or substract (if preceded by "-") from the time value represented by ticks

;Note: This format is the same used by the ASP.NET
;AJAX framework, described in;us/library/bb299886.aspx 

In the scenario you describe above you are getting a response that has a DateTimeOffset property using a different format.  That's why I'm so interested in knowing if the endpoint you are using was implemented using Microsoft WCF Data Services or a third party library like odata4j. 


Alex Trigo.

Mar 6, 2012 at 1:06 PM
Edited Mar 6, 2012 at 3:32 PM

Hi Alex,



I ran into this while testing with an OData SAP Gateway Service.


But is the spec you mentioned not different to the official odata spec link I mentioned?

Literal form of Edm.DateTimeOffset as used in URIs formatted as a JSON string


jsonDateTimeOffset = jsonDateTime



Mar 6, 2012 at 8:06 PM

Hi Joe,

   Thanks for the answer.  Can you share with me a network trace of the response please?  Also, I assume you are passing a metadata object when calling  / OData.request.

   The difference in the specs is what I want to sort out as well.  And thank you for bringing this into our attention :).


Alex Trigo. 




Mar 22, 2012 at 10:21 AM

Hi Alex,


sorry for the delay. I currently retried to reproduce the error but perhaps the service has been adapted. I get the dates now in the correct

Anyway thanks for your help.