Skip to content

.NET TimeZoneInfo fails to recognize historical invalid times after 2025 tzdb update for America/Asuncion #114476

Open
@michaelamaura

Description

@michaelamaura

Description

After updating the OS-level time zone database (tzdb) to reflect Paraguay’s permanent switch to UTC-3, .NET TimeZoneInfo incorrectly treats historically invalid times as valid and returns conflicting UTC offsets.

Paraguay switched to DST exactly "before midnight", thus skipping midnight:

  • Prior to the tz db update, tz.IsInvalidTime(new DateTime(2024, 10, 6, 0, 0, 0)) was true.
  • After the tz db update, tz.IsInvalidTime(new DateTime(2024, 10, 6, 0, 0, 0)) is false.

Also for historical dates tz.IsInvalidTime should return correct results to ensure correctness. Since there are also discussions about abolishing DST in the US and EU, we should also ensure that historical calculations there won't be affected by future timezone updates.

Impact:

  • Data Integrity: Historical dates are incorrectly validated, leading to errors in scheduling, auditing, or compliance.
  • Offset Mismatches: DateTime and DateTimeOffset yield conflicting UTC offsets for the same logical time. (Edit: not reproducible)

Reproduction Steps

using System;
					
public class Program
{
	public static void Main()
	{
		var tz = TimeZoneInfo.FindSystemTimeZoneById("America/Asuncion");
		var shouldBeInvalid = new DateTime(2024, 10, 6, 0, 0, 0);
		
                // as a bonus show how offsets are handled incorrectly when passing invalid dates to tz.GetUtcOffset
		var utcOffsetFromDateTime = tz.GetUtcOffset(shouldBeInvalid);
		var dateTimeOffset = new DateTimeOffset(shouldBeInvalid, utcOffsetFromDateTime);
		var utcOffsetFromDateTimeOffset = tz.GetUtcOffset(shouldBeInvalid);
		
		Console.WriteLine($"Invalid: {tz.IsInvalidTime(shouldBeInvalid)}");
		Console.WriteLine($"UtcOffset: {utcOffsetFromDateTime}");
		Console.WriteLine($"UtcOffset: {utcOffsetFromDateTimeOffset}");
	}
}

Expected behavior

Should print (still does no .NET fiddle as of writing this issue https://dotnetfiddle.net/Ws9LR7):

Invalid: True
UtcOffset: -04:00:00
UtcOffset: -04:00:00

Actual behavior

On azure build agent with ubuntu-latest (agent version '4.253.0' , i.e. Ubuntu 24.04 with tzdata=2025b-0ubuntu0.24.04) it will print:

Invalid: True
UtcOffset: -04:00:00
UtcOffset: -03:00:00

Regression?

Works still on .NET fiddle and did work on Azure build agent version 20250323.1.0 (i.e. Ubuntu 24.04 with tzdata=2024a-2ubuntu1)

Known Workarounds

  • use NodaTime
  • use the inconsistency between GetUtcOffset(DateTime) and GetUtcOffset(DateTimeOffset) to determine whether a time is invalid

Configuration

Reproducible on Azure build agents "ubuntu-latest", agent version "4.253.0".

Other information

Changes to tzdb probably affecting this: eggert/tz@486e1e8

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions