Ext.Net.DateField submit date is shifted by local time zone
Found: 5.2.0 Ext.NET forum thread: Problem send date directmethod
The #1605 issue introduced a problem with Date (and DateTime) objects being passed between client and server such that a returned date will always be shifted by the time zone offset, as native implementation of JSON converts dates to UTC string representation.
That is, if time zone is UTC+2, a date of 2020-02-02 04:00:00 will be output as the 2020-02-02 02:00:00 when it is submitted to the server.
One way to revert this behavior from the native browser implementation of Date.prototype.toJSON() is redefining it as:
Date.prototype.toJSON = function () {
var ejs_encoded = Ext.JSON.encodeDate(this);
return ejs_encoded.substring(1, ejs_encoded.length - 1);
}
Also, setting Ext JS's USE_NATIVE_JSON back to false addresses the issue. There's some implications, as the change will only be available after the page's init script is run, which may effectively ignore the setting (always being true) during page load.
A proper implementation for Ext.NET should not change the browser's native prototype of the JSON converter, yet preserve the sent date object's value without the time zone shift.
This issue is most likely also present in pure Ext JS as the effective value of date objects will result into different strings.
A "proper" solution to this seems to be, whenever we are to convert a date using native json parser, deduce the timezone offset as explained in this stackoverflow question: JavaScript Date.toJSON() produces a date which has wrong hours and minutes .