Repository navigation
Description
Description
On .NET 11 RC1, DateTime.ToUniversalTime() on a DateTimeKind.Local value that falls in the spring-forward gap (an invalid time) no longer subtracts the standard offset, as documented:
If the date and time instance value is an invalid time, this method simply subtracts the local time from the local time zone's UTC offset to return UTC.
It appears to add the offset instead. For W. Europe Standard Time (UTC+1, DST +2), 2026-03-29 02:30 local becomes 03:30Z instead of 01:30Z.
The result also disagrees with the rest of the runtime for the same value:
TimeZoneInfo.Local.GetUtcOffset(local)returns+01:00;new DateTimeOffset(local).UtcDateTimereturns01:30Z.
It also breaks ordering: 02:30 local maps to 03:30Z, which is later than 03:00 local → 01:00Z.
Reproduction Steps
Run on a machine whose local time zone is W. Europe Standard Time (or Europe/Berlin, Europe/Rome, …):
foreach (var wallClock in new[]
{
new DateTime(2026, 03, 29, 01, 59, 00),
new DateTime(2026, 03, 29, 02, 00, 00), // invalid
new DateTime(2026, 03, 29, 02, 30, 00), // invalid
new DateTime(2026, 03, 29, 02, 59, 00), // invalid
new DateTime(2026, 03, 29, 03, 00, 00),
})
{
var local = DateTime.SpecifyKind(wallClock, DateTimeKind.Local);
Console.WriteLine(
$"{wallClock:HH:mm} invalid={TimeZoneInfo.Local.IsInvalidTime(local),-5} " +
$"ToUniversalTime={local.ToUniversalTime():HH:mm}Z " +
$"GetUtcOffset={TimeZoneInfo.Local.GetUtcOffset(local)} " +
$"DateTimeOffset={new DateTimeOffset(local).UtcDateTime:HH:mm}Z");
}Expected behavior
This is the .NET 10.0.12 output:
01:59 invalid=False ToUniversalTime=00:59Z GetUtcOffset=01:00:00 DateTimeOffset=00:59Z
02:00 invalid=True ToUniversalTime=01:00Z GetUtcOffset=01:00:00 DateTimeOffset=01:00Z
02:30 invalid=True ToUniversalTime=01:30Z GetUtcOffset=01:00:00 DateTimeOffset=01:30Z
02:59 invalid=True ToUniversalTime=01:59Z GetUtcOffset=01:00:00 DateTimeOffset=01:59Z
03:00 invalid=False ToUniversalTime=01:00Z GetUtcOffset=02:00:00 DateTimeOffset=01:00Z
Actual behavior
This is the .NET 11.0.0-rc.1.26425.128 output:
01:59 invalid=False ToUniversalTime=00:59Z GetUtcOffset=01:00:00 DateTimeOffset=00:59Z
02:00 invalid=True ToUniversalTime=03:00Z GetUtcOffset=01:00:00 DateTimeOffset=01:00Z
02:30 invalid=True ToUniversalTime=03:30Z GetUtcOffset=01:00:00 DateTimeOffset=01:30Z
02:59 invalid=True ToUniversalTime=03:59Z GetUtcOffset=01:00:00 DateTimeOffset=01:59Z
03:00 invalid=False ToUniversalTime=01:00Z GetUtcOffset=02:00:00 DateTimeOffset=01:00Z
Only the invalid times are affected, and the error is always +2h. That is consistent with the offset being added instead of subtracted (02:30 + 01:00 = 03:30).
Regression?
Yes. It works on .NET 10.0.12 and fails on .NET 11.0.0-rc.1.26425.128. It is possibly related to the time zone rewrite in #119662. The corner-case regressions #126940 / #127009 came from the same change.
Known Workarounds
Compute the UTC value from TimeZoneInfo.Local.GetUtcOffset(local), which behaves the same on both versions, or use new DateTimeOffset(local).UtcDateTime.
Configuration
- .NET 11.0.0-rc.1.26425.128 (compared with .NET 10.0.12)
- Windows 11 Pro 10.0.26200, x64
- Local time zone:
W. Europe Standard Time
Other information
TimeZoneInfo.ConvertTimeToUtc(local)throwsArgumentExceptionfor these values on both versions, as expected. So the difference seems limited to theNoThrowOnInvalidTimepath used byToUniversalTime().- Not tested on Linux/macOS or with a time zone behind UTC.
Activity
dotnet-policy-service commentedon Sep 29, 2026
Tagging subscribers to this area: @dotnet/area-system-datetime
See info in area-owners.md if you want to be subscribed.
tarekgh commentedon Sep 29, 2026
Thanks @Dona278 for reporting it!
jozkee commentedon Sep 29, 2026
isn't this sentence backwards? Shouldn't it be "subtracts the local time zone's UTC offset from the local time"?.
tarekgh commentedon Sep 29, 2026
Technically you are right. Mostly I am seeing cases user interpret it correctly even when written this way. 😄
Remove pre-existing Europe/Lisbon 1993 gap case from invalid-time test
Fix DateTime.ToUniversalTime for invalid local times in the DST gap (#…
[release/11.0] Fix DateTime.ToUniversalTime for invalid local times i…