riganti / dotvvm

Open source MVVM framework for Web Apps
https://www.dotvvm.com
Apache License 2.0
753 stars 97 forks source link

Add support for DateTimeOffset type #633

Open adamjez opened 6 years ago

adamjez commented 6 years ago

We should add support to DateTimeOffset type.

In the current version of DotVVM, user that uses DateTimeOffset have to add another DateTime property to viewModel to be able to properly format DateTime:

public DateTime OccuredAtLocal => OccuredAt.LocalDateTime;
public DateTimeOffset OccuredAt { get; set; }

It would be a much nicer to do it in a value binding: {value: OccuredAt.LocalDateTime}.

There is a slight issue that rendering it server-side could result in different DateTime then rendering it client-side. We can use Internationalization API to get local timezone from browser.

Then there is a question if we should support assigning to DateTimeOffset and if yes, how it should be done? What timezone should be used (local/utc)?

vstribrny commented 6 years ago

I think it’s natural to bind properties directly to DateTimeOffset type, like:

<bp:DateTimePicker SelectedDate="{value: SelectedDate}" /> where SelectedDate is DateTimeOffset property.

I know there probably are serialization/controls-related issues with that now, but it would be the proper DateTimeOffset support in my opinion. The offset part should be the local timezone from browser (not UTC).