EDIT 11-08-2015: I have confirmed this bug is fixed in 2.5.3, available via nuget as of 20-07-2015
EDIT: Microsoft confirmed that this is a bug that will be addressed in the next release of lightswitch, < 2.5.3 (link)
I have a simple LightSwitch HTML page with a DateTime TextBox that is databound to a SQL Server DateTime field (UTC +1).
When the page is rendered, the correct date is shown. However, when i update using
msls.application.applyChanges()
my DateTime TextBox value is incremented by one hour, even though the value hasn't changed, but the correct date is set in the database. I've tried to hack around this using JS but i haven't found a good solution yet.
I just don't get why the datetime is rendered correctly on load, but rendered incorrectly after update even though the value hasn't changed. If it were one way or the other i could just hack around it but now it's all inconsistent.
Is LightSwitch really this incompatible with datetime?
Edit: Found others that experience the same problem: https://social.msdn.microsoft.com/Forums/vstudio/en-US/90cd2036-0001-4f59-a2ad-a032dd04d9e1/html-date-picker-display-date-changing-on-save?forum=lightswitch&prof=required
Open msls-2.5.2.js
Locate this section of code:
entitySet._loadedEntities[entityData.__metadata.uri] = entity;
} else if (entityState === _EntityState.modified) {
originalEntityData = entityData.__original;
$.each(entityDetails.properties.all(), function (j, property) {
You need to add: convertDatesToLocal(changeResponse.data);
Example:
entitySet._loadedEntities[entityData.__metadata.uri] = entity;
} else if (entityState === _EntityState.modified) {
convertDatesToLocal(changeResponse.data);
originalEntityData = entityData.__original;
$.each(entityDetails.properties.all(), function (j, property) {
Hope this helps.