Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1175
igGrid UTC Dates not working
posted

I've read all of the articles for UTC dates for the newer versions but they aren't working.

MVC v4.17.2.183

Here's what I got:

    @(Html.Infragistics().Grid<TaskModel>()
          .PrimaryKey("TaskApprovalId")
          .ID("GlobalTasksGrid")
          .AutoGenerateColumns(false)
          .AutoGenerateLayouts(false)
          .EnableUTCDates(true)
          .Columns(column =>
          {
              column.For(m => m.TaskApprovalId).DataType("number").HeaderText(" ").Hidden(true);
              column.For(m => m.Location).DataType("string").Width("215").HeaderText("Location");
              column.For(m => m.Task).DataType("string").Width("195").HeaderText("Task").Template("[Task Name]");
              column.For(m => m.Employee).DataType("string").Width("155").HeaderText("Employee").Template("[Employee Name]");
              column.For(m => m.ApprovalDate).DataType("date").Format("dateTime").Width("180").HeaderText("Date")
                    .Template("<div align='center'>${ApprovalDate}</div>").DateDisplayType(DateDisplayType.Local);
          })
          .Features(feature =>
          {
             feature.Updating()
                    .EnableAddRow(false)
                    .EnableDeleteRow(true)
                    .EditMode(GridEditMode.None);
          })
          .AutoCommit(true)
          .DataSourceUrl(Url.Action("GetGlobalTasks"))
          .DataBind()
          .Render()
     )

EnableUTCDates set to true.  This notifies the datasource that the incoming date are in UTC format.  So it should convert it into a Date object.

LocalSchemaTransform is set to true by default, which is what we want.

The ApprovalDate column is set to DateTime and the DateDisplayType is set to "local".

Unfortunately, the desired result is still the same.  The UTC date stored in the database is still rendered as such to the client.

Here's the data coming from the server:

The only thing that stands out is the Metadata.timezoneOffset which I don't set myself.

Thoughts?

Parents
No Data
Reply
  • 1175
    Offline posted

    So I've read a few other articles:

    https://es.infragistics.com/community/forums/f/ignite-ui-for-javascript/111827/convert-utc-time-to-browser-timezone-in-iggrid

    This particular one pointed to DateTime.Kind being set to Unspecified with Entity Framework.  So far that assumption is true.  I checked the code and sure enough it was set to that.  So I changed it programmatically before serialization to Utc.  But now the dates render in the UI another 5 hours past than what it is supposed to be.  Date was set at 2019-10-15T22:34:02.513Z but I actually did it at 17:34:02 local time.

    Seems to be going 5 hours in the wrong direction.  Now I'm completely stumped.  In addition, I would expect that if I change the DateDisplayType from UTC to Local I would see the dates change but I don't.

Children