How is Edm.Time handled in datajs?

Apr 29, 2013 at 2:46 PM

how does datajs handle Edm.Time?
This is not converted to a JS Data object like EDM.DateTime right?
It is somehow converted in a structure with a ms property.
Why this is done and is this done everytime or can I/you also convert it into a JS Date object?


May 6, 2013 at 10:38 PM
Edited May 6, 2013 at 10:40 PM
Hi Joe82,

Datajs doesn't convert the EDM.Time to EDM.DateTime, it only converts it ms and store it in ms property.
This is done because EDM.Time represents a time duration while EDM.DateTime represents a Date.
If you convert the value to JavaScript date like for example new Date(milliseconds) the value won't be true because the JS date is milliseconds since 1970/01/01
while the EDM.Time value represents a duration.
hope this helps.

May 7, 2013 at 3:00 PM
Edited May 7, 2013 at 3:05 PM
Hi Hussein,

the spec says:
Represents the time of day with values ranging from 0:00:00.x to 23:59:59.y, where x and y depend upon the precision
Example 1: 13:20:00
So for me this isn't a time duration but a time with a timezone. See also here:

Also if you convert that value via new Date(milliseconds) the time should be always the same (depending on your timezone it might be different but with e.g. myDate.getUTCHours() you always get the same result as from the server...)
May 7, 2013 at 5:55 PM
Sorry for the mistake.
The mapping of Edm.Time in CLR space is TimeSpan which can be used as duration or time of day.
So I think that it's just semantic difference.

So if the the field represents time of day you can convert it normally to JS Date.

I found an old discussion about this in WCF DS forum here