Problem with Edm.Time

Sep 13, 2012 at 3:06 PM


I have an OData service which has a property of type Edm.Time which is nullable.

When a time value is null the server returns e.g.


"d": {
"results": [
  "ID": 1,
"Col1": "PT0H35M48S",
"Col2": "/Date(1354665600000)/",
"Col3": "/Date(1305115259999)/"
  "ID": 2,
"Col1": null,
"Col2": "/Date(1354665600000)/",
"Col3": "/Date(1354708859999)/"
"__count": "2"


Now datajs crashes with Invalid duration value.

it happens in the jsonParser function:


if (property.type === "Edm.DateTime" || property.type === "Edm.DateTimeOffset") {
if (propertyValue) {
propertyValue = parseJsonDateString(propertyValue);
if (!propertyValue) {
throw { message: "Invalid date/time value" };
value[propertyName] = propertyValue;

} else if (property.type === "Edm.Time") {
value[propertyName] = parseDuration(propertyValue);


There is no check liken in the Edm.DateTime section if the propertyValue is defined or not.

Is this a bug?


Another question:


Why parses datajs the Edm.Time values different than datevalues?

As a result I get an object which contains the time value... under 'ms':

var result = { ms: ms, __edmType: "Edm.Time" }; // in parseDuration

Why is the value not directly under the time property?



jsonParser function
Sep 18, 2012 at 5:47 PM

Hi Joe,

    Indeed the null check looks like a bug in datajs. Thanks for bringing this to our attention.  As why we parse Edm.Time values like that is because they represent time span values and not actual time values ( the OData documentation is a little bit confusing in this regards).  So being a duration we parse it into an object that stores the time span value as miliseconds under the ms property.


Alex Trigo.