Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time zones won't work as-is with Blazor WASM #35

Open
paulsterling opened this issue May 3, 2022 · 2 comments
Open

Time zones won't work as-is with Blazor WASM #35

paulsterling opened this issue May 3, 2022 · 2 comments
Labels
triage Needs investigation type: bug Something isn't working
Milestone

Comments

@paulsterling
Copy link
Contributor

paulsterling commented May 3, 2022

I believe the recent time zones feature addition will not work with Blazor WASM as it currently is implemented. I had done some work with time zones earlier this year with a WASM project and found that only the IANA zones are provided with the Blazor WASM runtime - from .NET 6. I understand this has to do with the way Blazor Interop passes dates to/from the JS. I don't think will require a big change to the way blazor_calendar has time zones implemented. Really the only change needs to be in ToTuiTimeZone in TUICalendarTimeZoneOption.

Rather than returning null when parsing the TimeZoneId, we could check to see which format is provided (IANA or Windows) and then either use TimeZoneInfo.TryConvertWindowsIdToIanaId() for Windows or just the provided TimeZoneInfo object if it's already an IANA TimeZoneId. Something along these lines

            // try to parse the id as a Windows Time Zone Id
            string timezoneName = string.Empty;
            if (!TimeZoneInfo.TryConvertWindowsIdToIanaId(timeZoneInfo.Id, out timezoneName))
            {
                // Not Windows or not found, use IANA
                timezoneName = timeZoneInfo.DisplayName;
            }

There is an open issue requesting support for both Windows and IANA TimeZoneIds (dotnet/runtime#64778) so maybe this won't be an issue for long.

Possibly, it might make sense to use something like the time zone converter library that has already solved the various time zone platform variations (https://devblogs.microsoft.com/dotnet/cross-platform-time-zones-with-net-core/).

@gismofx
Copy link
Owner

gismofx commented May 4, 2022

@paulsterling Thanks for taking the time to comment on this!

How about restricting time
entry to only IANA values? What would we be losing by restricting windows ids? (I suppose some existing data based on windows time zone could be affected?) I like your current idea to mitigate null return value.

I like that Nuget package, but they suggest updating frequently, (which is probably ok, but would rather a more stable option).

@paulsterling
Copy link
Contributor Author

@gismofx

I concur with prescribing use of the IANA time zone Ids. That way we'll be (more) platform agnostic and it should work with all Blazor runtimes across various platforms. Anyhow, Windows time zones can be strangely named IMHO but the IANA time zones follow a more predictable pattern.

@gismofx gismofx added type: bug Something isn't working triage Needs investigation labels Jun 14, 2022
@KevinKrueger KevinKrueger added this to the v.1.0.0 milestone Feb 25, 2024
@github-project-automation github-project-automation bot moved this to In progress in v.1.0.0 Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Needs investigation type: bug Something isn't working
Projects
Status: In progress
Development

No branches or pull requests

3 participants