How can we improve Breeze.js?

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.

* When a JavaScript Date contained in a breeze DataProperty of type "DateTimeOffset" is serializeed by the breeze client, the dates are always converted to UTC. (example: if I was sending the same date back to the server that was retrieved in the example above, it would have been changed to 2013-15-05T13:51:21.123+00:00, regardless of the timezone of the client device.

Breeze should make use of the timeZoneOffset part of JavaScript dates, and keep this when serializing on the client. The server would then be able to get both the date, time and timeZoneOffset sent by the client into the DateTimeOffset type on the server.

My change request is therefore:

A breeze DataProperty of type "DateTimeOffset" should be serialized persisting the TimeZoneOffset of the JavaScript date. The timeZoneOffset would then be the same once deserialized to "DateTimeOffset" on the server and also when written to a datetimeoffset field on the SQL Server.

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.

77 votes
Vote
Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
You have left! (?) (thinking…)
Jørn Andre Sundt shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

3 comments

Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
Submitting...
  • Christian Crowhurst commented  ·   ·  Flag as inappropriate

    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!

  • Christoph commented  ·   ·  Flag as inappropriate

    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,

    Christoph

Feedback and Knowledge Base