I have an ODATA node, which automatically throws data in Json format.
One of the properties in this object contains a time lapse ISO 8601 , because it is generated using < strong> TimeSpan
(from .Net)
For example, a lapse of 7 hours is serialized like this:
"PT7H"
I consume this API from a client in AngularJs and I need to add and subtract hours and minutes, and JavaScript does not have a native data type for TimeSpan.
You who are JavaScript ninjas How do you handle this type of situation? I mean, how do I convert that format to a "friendly" JavaScript object that I can use?
Which library is recommended? Moment.js? Date.js?
Here are some pitiful attempts of mine:
var resultado=JSON.parse(valorTS); //mismo valor
var resultado=Date(valorTS); //Invalid date
(Same question: link )