-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
TimeZoneInfo.GetSystemTimeZones produces unexpected results in Blazor WASM for .NET 5 #44840
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Some timezone information has been reduced or removed to save size in the deployed app. There are some options to resolve this but we'd be interested to know what use case you are trying to support? |
I'm currently just trying to allow users to select a time zone for their company in my application I'm building. How can I get the full time zone information, if it's not enabled by default? |
Note that this will significantly increase your download size. I think there is still some work with sharding. I ran into the same issue, I just generate a list on the server and let the user pick from there in the edit form. For date time formats and utc offset, I keep a user model on a singleton service that updates the format for other services for displaying dates, user avatar menu etc. This user model is updated after login. |
Interestingly enough, I tried the documentation you referenced there, and it doesn't seem to fix the issue. Perhaps I'm doing something wrong. It is really unfortunate that we have to roll our own time zone lists but I guess that's the only viable option here. |
Tagging subscribers to this area: @CoffeeFlux Issue DetailsDescribe the bugWhen using TimeZoneInfo.GetSystemTimeZones method in Blazor WASM on .NET 5, I am getting a strange list returned.
Is there any other method to return all available time zones that I am not aware of? To ReproduceUse TimeZoneInfo.GetSystemTimeZones inside of a Blazor WASM page with .NET 5.
|
@tqiu8 can you take a look at this. It seems like the list filtering is causing issues and we should possibly revisit that choice. |
@lewing the list filtering is definitely limiting the system timezones; however for the problem of the display names I believe it's because the StandardName might've been used instead of DisplayName. I can disable the filtering. |
@tqiu8 I suspect the name is coming from icu and has been removed there but please verify. It's possible we can fix that part with the included data |
@andersme finding the right size/feature/time balance is difficult but feedback is appreciated. If it is of any help we can point you to the parts of the build process that construct this data. |
@lewing I simply want the option to be able to get the complete list of time zones. I understand that this may cause additional load size, but that's okay. I guess I also would like to understand what the differences is between .NET Core 3.1 and .NET 5, because the list return in .NET Core 3.1 seems much more comprehensive. |
The DisplayName problem is described in this issue: #16232 |
Here is the complete output from my client side logging using v5.0.2, it produced 14 time zones. The same test on server side produced 140 time zones.
|
currentTimeZone = TimeZoneInfo.Local; So it means i will have to wait to .NET 6 is released, don't want to use Preview version as this is problem occurring in production, will use some other method to fix it. |
@nssidhu - That's a slightly different area than what this issue is about. However, I assume you are still talking about Blazor WASM? If so, Note, this part of .NET on WASM works the same way in .NET 5 and 6. There's some minor refactoring between, but in both cases the time zone is read using the ECMAScript |
Confirming that both are giving the same value 'America/Los_Angeles'. |
Hmm, currentTimeZone = TimeZoneInfo.Local; this turned out to be system setting on the VM that code was running on. It was set to PST |
It seems like this is fixed for net6, so closing. If there's anything actionable left, let me know and I can reopen or create a new issue. |
Describe the bug
When using TimeZoneInfo.GetSystemTimeZones method in Blazor WASM on .NET 5, I am getting a strange list returned.
Is there any other method to return all available time zones that I am not aware of?
To Reproduce
Use TimeZoneInfo.GetSystemTimeZones inside of a Blazor WASM page with .NET 5.
The text was updated successfully, but these errors were encountered: