OData / odataorg.github.io

Staging site and collaboration repository for http://www.odata.org
MIT License
63 stars 101 forks source link

DateTimeOffset handling in formatDateTimeOffset #197

Open tonyjoanes opened 5 years ago

tonyjoanes commented 5 years ago

We're using some DateTimeOffset datatypes in our MSSQL database and require the offset to be passed back to the server.

The function formatDateTimeOffset performs a hasOffset check on the value passed in but this only receives a DateTime from what I have seen. The means it never returns a DateTimeOffset from the function and we can't receive the correct value back on the server.

The check it performs on the value is the following snippet of code and it assumes fields that the parameter never has.

var isDateTimeOffset = function (value) {
        /// <summary>Checks whether a Date object is DateTimeOffset value</summary>
        /// <param name="value" type="Date" mayBeNull="false">Value to check.</param>
        /// <returns type="Boolean">true if the value is a DateTimeOffset, false otherwise.</returns>
        return (value.__edmType === "Edm.DateTimeOffset" || (!value.__edmType && value.__offset));
    };

I can hack around this but I am wondering if there is some setup missing from somewhere to get DateTimeOffsets to play nicely with the BreezeJS and DataJs frameworks.