Skip to content

Commit 3702427

Browse files
authored
fix: OnLocalTimeZoneChanged method (#5)
Refactor OnLocalTimeZoneChangedDetailed method to simplify time zone retrieval and improve clarity in null handling (cherry picked from commit 41c54c6)
1 parent 14649ba commit 3702427

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/BlazorLocalTime/Components/LocalTimeForm.razor.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,16 @@ public void Dispose()
4343

4444
private async void OnLocalTimeZoneChangedDetailed(object? sender, TimeZoneChangedEventArgs e)
4545
{
46-
var prevTimeZone = e.PreviousTimeZone ?? LocalTimeService.BrowserTimeZoneInfo;
47-
var currTimeZone = e.CurrentTimeZone ?? LocalTimeService.BrowserTimeZoneInfo;
46+
var prevTimeZone = e.PreviousTimeZone;
47+
var currTimeZone = e.CurrentTimeZone;
4848
if (currTimeZone == null)
4949
{
50-
// If current timezone is null, we cannot proceed with the conversion.
51-
// This can happen if the browser failed time zone detection.
50+
// If current timezone is null, this can happen if the browser failed time zone detection.
5251
return;
5352
}
5453
if (prevTimeZone == null)
5554
{
56-
// timezone is available now
55+
// timezone is available now !
5756
await InvokeAsync(StateHasChanged);
5857
return;
5958
}

0 commit comments

Comments
 (0)