TimeZoneInfo.GetSystemTimeZones() doesn't support localized display names

Open
#114,543 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp, linux

Research direction

Reproduce the minimal API on .NET 8.0.115 under Ubuntu and compare its TimeZoneInfo.GetSystemTimeZones() display names with .NET 6, changing CurrentUICulture to en, de, and zh. Done means the returned time-zone list uses the requested UI culture rather than the operating system locale.

Written by the indexing model from the issue text.

Description

area-System.DateTime regression-from-last-release
Description

Our app have a method to return a localized list of time zones (simplified):

        public IActionResult GetAllTimeZone(string lang = "") {
            var reqCult = CultureInfo.GetCultureInfo(lang);
            CultureInfo.CurrentUICulture = reqCult;
            CultureInfo.CurrentCulture = reqCult;
            CultureInfo.DefaultThreadCurrentUICulture = reqCult;
            CultureInfo.DefaultThreadCurrentCulture = reqCult;

            TimeZoneInfo.ClearCachedData();
            return _mapper.Map<TimeZoneInfoDto[]>(TimeZoneInfo.GetSystemTimeZones());
        }

We were using .net 6.0 in docker (Linux)
Calling it with "en", "de", "zh" produced expected results.

However when we upgraded to .net 8.0 the same code broke. It now produces always the same results not respecting CultureInfo.CurrentUICulture.

Reproduction Steps

Create minimal api project with one method that returns TimeZoneInfo.GetSystemTimeZones() as described earlier

Expected behavior

List of timezones with localized display names

Actual behavior

List of timezones with display names of the OS locale. When running in container it returns always English names. On dev machine it uses the OS locale.

Regression?

No response

Known Workarounds

No response

Configuration

Dev machine
dotnet SDK
Version: 8.0.115
Commit: 9c0387c3ea

Environment:
OS Name: ubuntu
OS Version: 24.04
OS Platform: Linux
RID: ubuntu.24.04-x64
Base Path: /usr/lib/dotnet/sdk/8.0.115/

Host:
Version: 8.0.15
Architecture: x64
Commit: 50c4cb9fc3

.NET SDKs installed:
6.0.136 [/usr/lib/dotnet/sdk]
8.0.115 [/usr/lib/dotnet/sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.36 [/usr/lib/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.15 [/usr/lib/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.36 [/usr/lib/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.15 [/usr/lib/dotnet/shared/Microsoft.NETCore.App]

Other information

No response

Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/runtime

All issues in dotnet/runtime

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.