Hello,
We are attempting up update from version 16.2 to 17.1. We are using a row edit dialog to edit existing DateTime data and the date is changing on submit.
The date we are sending on the server is 04/01/2013 at midnight. At first, we tried updating the row without changing any data. It appeared the date was changing, but we found that EnableUTCDates was set to TRUE for the DateTimeEditor, but was not set for the Grid. So we set this option to TRUE for both the grid and editor. This fixed the initial issue. Or second test involved updating the date itself. We changed the date from 4/1/2013 to 4/2/2013 and then back to 4/1/2013 using the datepicker. When we do this, the date is changing when it gets to the server.
In 16.2, the data looked like this when it got to the server:
{{"Id": 59,"StartDate": "2013-04-01T00:00:00Z"}}
In 17.1, we are seeing the following date:
{{"Id": 59,"StartDate": "2013-04-01T16:00:00Z"}}
What are the recommended settings for preventing a date from changing on submit to the server? We would expect this to work exactly the same as it did in 16.2 as we didn't have any problems with the dates in that version.
Thanks,
Paul
Hello Paul,
If you are using EF, your model's DateTime-s are probably loaded as DateTimeKind.Unspecified, which may provide some inconsistent results as Newtonsoft.JSON doesn't send offsets for such objects. The client then receives an incomplete ISO formatted date that it interprets differently between browsers. If you are sending the data through a controller decorated with a GridDataSourceAction attribute or just sending it with the view, the MVC helpers alleviate that by forcing Newtonsoft.JSON to interpret such DateTime-s as UTC at least ensuring all clients interpret them in the same way, however, this might not be correct for your app.
It's a pretty complicated topic overall and earlier versions did more work under the hood to cover basic scenarios while failing in other specific use-cases.
One thing you could try out just to give you an idea of how it should behave is to provide a hardcoded object for your data with the DateTime-s specified as UTC. Then the roundtrip should be consistent. You could also try not specifying DateDisplayType for the column leaving the MVC wrapper to manually handle offsets showing Dates as they would be displayed on the server (this will again only work if you are passing your model through the MVC helpers).
In any case you don't need to specify EnableUTCDates for the DatePicker as it is currently only a communication option and the DatePicker inside the grid doesn't send requests directly to the server for it to matter.
I will try to isolate a sample in which the behavior is exactly as you define it so I can provide you with more information on how to resolve this.
Best regards,
Stamen Stoychev
Hi Elizabeth,
Thanks for the links, they were helpful. I'm still having a tough time with this though. I can't seem to get the results that I am looking for. To make things easier, I tested this with my server and client in the same timezone, UTC-05:00. The date from my server is 4/1/2013 12:00:00 AM. I'm using C# MVC to generate the grid control and then I'm using JsonConvert.DeserializeObject<List<Transaction<T>>>(a_Controller.HttpContext.Request.Form["ig_transactions"]) to deserialize the data on the server side, so I'm not sure if that has something to do with the issue I am seeing. Also, I'm using a row edit dialog to update the data and a ColumnEditorType.DatePicker.
I tried using the DateDisplayType.UTC as mentioned in the article and below are my results (I'm showing this for my sanity as well). Previously, I tested this without using the DateDisplayType setting and the results from those tests are not included, but that didn't work either (I can provide those tests if needed though). Below, where it says "CHANGE RESULT", this is the resulting date that is passed back to the server when I used the DatePicker to change the date to 4/2/2013 and then back to 4/1/2013. For the "NO CHANGE RESULT", I didn't make any changes to the date and just hit "Done" to submit my changes.
gridModel.EnableUTCDates = true;updatingSetting.DateEditorOptions.EnableUTCDates = true;column.DateDisplayType = DateDisplayType.UTCCHANGE RESULT: 4/1/2013 4:00:00 PMNO CHANGE RESULT: 4/1/2013 12:00:00 AM
gridModel.EnableUTCDates = false;updatingSetting.DateEditorOptions.EnableUTCDates = true;column.DateDisplayType = DateDisplayType.UTC;CHANGE RESULT: 4/1/2013 4:00:00 PMNO CHANGE RESULT: 3/31/2013 8:00:00 PM
gridModel.EnableUTCDates = false;updatingSetting.DateEditorOptions.EnableUTCDates = false;column.DateDisplayType = DateDisplayType.UTC;CHANGE RESULT: 4/1/2013 12:00:00 PMNO CHANGE RESULT: 3/31/2013 8:00:00 PM
gridModel.EnableUTCDates = true;updatingSetting.DateEditorOptions.EnableUTCDates = false;column.DateDisplayType = DateDisplayType.UTC;CHANGE RESULT: 4/1/2013 8:00:00 PMNO CHANGE RESULT: 4/1/2013 12:00:00 AM
So I can't seem to get a 4/1/2013 12:00:00 AM date back to the server. Is there something I am missing?
EnableUTCDates behavior changed between 16.2 and 17.1. Here are some links that explain the new functionality and how to migrate the option.
https://www.igniteui.com/help/breaking-changes-2017-volume-1
https://www.igniteui.com/help/migrating-enableutcdates-option-in-17-1
https://www.igniteui.com/help/using-igniteui-controls-in-different-time-zones
If you have further questions, a case has been created for you and you can reply to this post to update it.
Elizabeth AlbertLocalization Engineer