gustavnavar / Grid.Blazor

Grid component with CRUD for Blazor (client-side and server-side) and ASP.NET Core MVC
GNU Lesser General Public License v2.1
696 stars 134 forks source link

Timezone functionality #224

Open veselinbg opened 3 years ago

veselinbg commented 3 years ago

Hi, The grid is great but I have an question about globalization and timezones.

How to present UTC datetime in blazor webassembly in different timezones ?

I want to use the client time zone and if we have a client in UK and USA I want they to see datetime in their local timezones.

Is it possible from scratch or I have to add some code for each datetime column ?

My idea is to use datetimeoffset and present the data in client local timezone.

And what about the export to excel ?

Best regards,

Veselin

gustavnavar commented 3 years ago

GridBlazor package version 2.1.4 has the following behavior:

All 3 demos are executed on the same server and database, but WASM - OData show different datetimes that the other ones.

So if you work with WASM - Odata projects, you can use any DateTime property and the column definition should be as follows:

c.Add(o => o.OrderDate).SetInputType(InputType.DateTimeLocal).SetFilterWidgetType("DateTimeLocal").Format("{0:yyyy-MM-dd HH:mm}");

The different behavior is due to the back-end systems used on each kind of project. OData enforces to use client time zones, and GridMvcCore to use server time zones.