Breeze clientside serialization of DateTimeOffset DataProperties
Thanks for addressing my case about supporting the CLR DateTimeOffset type in breeze (supported from v1.1.1).
Please look at this case for background information.
I have looked into how serialization of JsDate/DateTime/DateTimeOffset works in Breeze, and found a single shortage that defeats my idea of using DateTimeOffset on the server.
I believe that you will find my change suggestion reasonable.
In breeze, Dates are serialized in ISO-8601 format ("yyyy-MM-dd\THH:mm:ss.fffK") both by the breeze client and by JSON.NET configured by Breeze.WebAPI.
This is according to my expectations.
When a DateTimeOffset is serialized by JSON.NET on the server, the timezone part of the DateTimeOffset is reflected in the ISO-8601 serialized date string. (example: 2013-15-05T15:51:21.123+02:00).
This is also according to my expectations.
My change request is therefore:
Hoping for you to solve this. It is in my opinion the last missing link to be able to handle date/time/timezone offset 100% correctly.
Christian Crowhurst commented
When I was investigating solutions, I pulled together a horrible hack that allowed me to store a DatetimeOffset that included the local client timezone. I have a note to go back and rip it out with a solution that hopefully would take advantage of a feature in breeze, as per the breeze release notes:
A new "serializerFn" property has been added to both the MetadataStore and the EntityType classes. This property, if present, mediates the entity serialization process.
I haven't revisited it yet!
We are currently migrating our project to breeze and angular and so far I love breeze. But now I started migration handling of date/times and I got a little bit into troubles.
I am having the same problems finding a consistent solution for storing date/time currently with Breeze. Moreover I want to make sure that I am not missing any information and doing it maybe wrong on my side. I searched now for the entire day all the stackoverflow information I could find about handling date/time with breeze, but I am not sure if I misunderstood.
If I read the text above then this means that from client to server always UTC is sent, am I right ? So no matter if using DateTimeOffset on server side, I will never get the local time of the user nor the timezone offset of the user, right ? This is also what I see in my first tests and what is written here (http://www.breezejs.com/previous-release-notes): "Since the Breeze client transmits all dates to the server as UTC dates"
But when I read the text here (http://www.breezejs.com/documentation/date-time): "that means that the timezone of the value on the server will be carried over to the value on the client (and vice versa)" I don't understand how timezone is carried over from the client to the server if only UTC is sent?
Am I missing something and doing wrong or is the above already implemented or how can be the timezone information currently transported from client to server ? In my case the timezone is actually not so important, its more the local date that I need.
Is there currently a way to get local date/time from breeze client to the breeze server as well as the UTC time or local time including timezone so we can convert to UTC on server side?
Thanks for your feedback and help,
Christian Crowhurst commented
A related question came up on stackoverflow asking how to preserve the client's timezone offset: