TimeZoneInfo.CreateCustomTimeZone Not Obeying disableDaylightSavingTime Parameter
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 46/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- csharp
- Domain
- operating-systems
Research direction
Start in src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.cs at CreateCustomTimeZone, then trace how its adjustmentRules are used by ConvertTimeFromUtc. Run the supplied reproduction on the affected runtime and verify that a custom zone created with disableDaylightSavingTime=true ignores daylight-saving adjustments while retaining the expected base offset.
Written by the indexing model from the issue text.
Description
Description
When calling the TimeZoneInfo.CreateCustomTimeZone method overload that accepts the disableDaylightSavingTime parameter and then subsequently calling TimeZoneInfo.ConvertTimeFromUtc during a daylight savings timeframe it returns a DST adjusted time but shouldn't.
Reproduction Steps
TimeZoneInfo astTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Atlantic Standard Time");
TimeZoneInfo astDstDisabledTimeZone = TimeZoneInfo.CreateCustomTimeZone(
astTimeZone.Id,
astTimeZone.BaseUtcOffset,
astTimeZone.DisplayName,
astTimeZone.StandardName,
astTimeZone.DaylightName,
astTimeZone.GetAdjustmentRules(),
true);
Console.WriteLine("AST with DST Enabled (UTC-3): " + TimeZoneInfo.ConvertTimeFromUtc(DateTime.Parse("4/1/2025 12:00:00"), astTimeZone));
Console.WriteLine("AST with DST Disabled (UTC-4): " + TimeZoneInfo.ConvertTimeFromUtc(DateTime.Parse("4/1/2025 12:00:00"), astDstDisabledTimeZone));
Expected behavior
AST with DST Enabled (UTC-3): 4/1/2025 9:00:00 AM
AST with DST Disabled (UTC-4): 4/1/2025 8:00:00 AM
Actual behavior
AST with DST Enabled (UTC-3): 4/1/2025 9:00:00 AM
AST with DST Disabled (UTC-4): 4/1/2025 9:00:00 AM
Regression?
When run with .Net Framework 4.7.2 it produces the expected output.
I also tested on .Net Core 3.1 and .Net 5 through .Net 9 and they all have the bug.
Known Workarounds
Pass null for the adjustmentRules parameter.
Configuration
- Which version of .NET is the code running on? .Net 9
- What OS and version, and what distro if applicable? Windows 11
- What is the architecture (x64, x86, ARM, ARM64)? x64
- Do you know whether it is specific to that configuration? I don't
Other information
Possibly in the CreateCustomTimeZone function. If DST is enabled and there are adjustment rules it clones them. However, if DST is disabled it just passes through the rules to the TimeZoneInfo constructor. Though maybe it should be discarding the adjustment rules in TimeZoneInfo constructor itself to cover more use cases.
I presume discarding of the rules is the itended implemention based on the documentation.
disableDaylightSavingTime Boolean
true to discard any daylight saving time-related information present in adjustmentRules with the new object; otherwise, false.
- Dominant language
- C#
- Stars
- 18.3k
- Forks
- 5.6k
- PR merge metrics
- PR metrics pending
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dotnet/runtime
-
agentic-workflows untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
area-System.Reflection blocking-clean-ci-optional Known Build Error os-mac-os-x untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
area-CodeGen-coreclr untriaged
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
agentic-workflows untriaged
Difficulty 1/5 Under an hour Newbie friendliness 78/100
-
area-VM-meta-mono untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SubtitleEdit/subtitleedit#15108 · 1 comment ·
-
area/docs-content Bug pulumi/docs
Difficulty 1/5 1-3 hours Newbie friendliness 94/100
-
Create parent directories only after the containment check in InstallHelper.TryExtractToDirectory Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
PowerShell/PSResourceGet#2056 ·