Toolbelt.Blazor.TimeZoneKit
2.1.0
dotnet add package Toolbelt.Blazor.TimeZoneKit --version 2.1.0
NuGet\Install-Package Toolbelt.Blazor.TimeZoneKit -Version 2.1.0
<PackageReference Include="Toolbelt.Blazor.TimeZoneKit" Version="2.1.0" />
paket add Toolbelt.Blazor.TimeZoneKit --version 2.1.0
#r "nuget: Toolbelt.Blazor.TimeZoneKit, 2.1.0"
// Install Toolbelt.Blazor.TimeZoneKit as a Cake Addin
#addin nuget:?package=Toolbelt.Blazor.TimeZoneKit&version=2.1.0
// Install Toolbelt.Blazor.TimeZoneKit as a Cake Tool
#tool nuget:?package=Toolbelt.Blazor.TimeZoneKit&version=2.1.0
Blazor Time Zone Kit
Summary
This is a class library as a NuGet package for Blazor browser application.
This package provides system time zones set, and local time zone initialization, for Blazor browser application.
Note
At this time, the version of Blazor is v.0.6.0, it doesn't contain any time zone info, and local time zone is always UTC wherever.
See also:
- Blazor Issue #663 - TimeZone issues related to Mono?
- Blazor Issue #1166 - DateTime always displays as UTC
- Mono Issue #6368 - WebAssembly: Missing Timezone implementation
How to install and use it?
Step.1 - Install this package.
> dotnet add package Toolbelt.Blazor.TimeZoneKit
Step.2 - call UseLocalTimeZone()
extension method in Configure()
method of startup class.
...
using Toolbelt.Blazor.Extensions.DependencyInjection;
public class Startup
{
...
public void Configure(IBlazorApplicationBuilder app)
{
app.UseLocalTimeZone();
...
That's all!
How does it work?
There is no magic.
This library contains all the system time zone information as a C# code.
(see: "TimeZoneKit.CreateSystemTimeZones.cs")
And, this library also contains mapping information for converting IANA time zone names to .NET time zone IDs.
(see: "TimeZoneKit.IANAtoTZIdMap.cs")
UseLocalTimeZone()
extension method in this library invokes "Intl.DateTimeFormat().resolvedOptions().timeZone"
JavaScript code to get the current time zone name (IANA name) on the web browser.
UseLocalTimeZone()
extension method also set up the system time zone set and local time zone information by accessing undocumented / non public members in System.TimeZoneInfo
class.
Note
- WARNING - This library accesses private members of
System.TimeZoneInfo
using the "Reflection" .NET API, so it may break in future .NET runtime (mono.wasm) release. - In my test case, this package increased the size of the sample Blazor browser application content by 154 KB. (by 20KB gzip transfer.)
License
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.AspNetCore.Blazor.Browser (>= 0.6.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|
v.2.1.0
- Blazor v.0.6.0 support - it was signed strong name.
- Update time zone information
- Morocco Standard Time
- Namibia Standard Time
- Fiji Standard Time
v.2.0.0
- BREAKING CHANGE: Fix namespace of TimeZoneKitExtension class.
v.1.0.0
- 1st release.