Skip to content

Blazor Webassembly: Wrong time zone information for Africa/Cairo Time zone #111146

Open
@sherif-elmetainy

Description

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

In 2024, the Africa/Cairo daylight saving (summer time GMT+3) ended on midnight of Friday, November 1st 2024, where the clock was set back one hour to start the standard time (winter time GMT + 2).

In the below code, Offset should be 03:00:00 because on October 31 at 9AM it's still summer time. This is the case with the code executed on the server (Server Side Rendering).
However, when the same code is executed on the client (Web Assembly), the Offset is 02:00:00.

@page "/"

<PageTitle>Home</PageTitle>

<h1>Hello, world!</h1>

<p>The following should output 3:00:00. It does so when rendering from server. However, when client side webassembly code is loaded and takes over, it displays 2:00:00.</p>
@Offset 


@code
{
    private DateTimeOffset Date { get; set; } = new DateTimeOffset(2024, 10, 31, 9, 0, 0, TimeSpan.FromHours(3));
    private TimeSpan Offset { get; set; }

    protected override void OnInitialized()
    {
        var timezone = TimeZoneInfo.FindSystemTimeZoneById("Africa/Cairo");
        Offset = timezone.GetUtcOffset(Date.DateTime);
        base.OnInitialized();
    }
}

Expected Behavior

The code snippet in the description, the Offset value should be 3:00:00. It's actually 2:00:00 which is incorrect.

Steps To Reproduce

The repo https://github.com/sherif-elmetainy/EgyptTimeZoneBug has a minimalistic reproduction of the bug in the Home.razor file in the Client project.

To reproduce in another project create a razor page with the following code

@page "/"

<PageTitle>Home</PageTitle>

@Offset 


@code
{
    private DateTimeOffset Date { get; set; } = new DateTimeOffset(2024, 10, 31, 9, 0, 0, TimeSpan.FromHours(3));
    private TimeSpan Offset { get; set; }

    protected override void OnInitialized()
    {
        var timezone = TimeZoneInfo.FindSystemTimeZoneById("Africa/Cairo");
        Offset = timezone.GetUtcOffset(Date.DateTime);
        base.OnInitialized();
    }
}

Exceptions (if any)

There are no exceptions thrown.

.NET Version

9.0.101

Anything else?

Microsoft.AspNetCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft Visual Studio Professional 2022 (64-bit) Version 17.12.3
Windows 11 Version 24H2 (OS Build 26100.2605)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions