Skip to content

Conversation

davidnguyen-tech
Copy link
Member

@davidnguyen-tech davidnguyen-tech commented Aug 11, 2025

Goal

Tries to fix #90269.

Issue summary

On Android, there are legacy TimeZones that have the same display name as non-legacy TimeZones. If developers get a list of all TimeZones and show them in UI, it can look like there are duplicate TimeZones based on the display name.

The fix we have for Android API > 25 is to use tzlookup.xml to filter out the legacy TimeZone IDs.

The problem is that for API <= 25, the tzlookup.xml file isn't available.

PR Description

  • This PR tries to detect legacy TimeZones by using the ucal_getCanonicalTimeZoneID function from the ICU library.
  • A canonical TimeZone ID is a "normalized" ID - basically we are able to pass a legacy ID and get the corresponding non-legacy ID (passing non-legacy ID works as well, in that case the returned value is an identity).

Problem with the PR

  • Sample program
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;

public static class Program
{
    public static int Main(string[] args)
    {
        ReadOnlyCollection<TimeZoneInfo> tzCollection = TimeZoneInfo.GetSystemTimeZones();
        return 42;
    }
}
  • In pal_timeZoneInfo.cs when we call ucal_getCanonicalTimeZoneID function in GlobalizationNative_GetCanonicalTimeZoneId method, the app crashes

@davidnguyen-tech davidnguyen-tech added this to the 10.0.0 milestone Aug 11, 2025
@davidnguyen-tech davidnguyen-tech changed the title [Android][CoreCLR] Filter legacy TimeZone IDs using ICU if tzlookup.xml isn't available [WIP][Android][CoreCLR] Filter legacy TimeZone IDs using ICU if tzlookup.xml isn't available Aug 13, 2025
@davidnguyen-tech davidnguyen-tech modified the milestones: 10.0.0, 11.0.0 Aug 14, 2025
@dotnet-policy-service dotnet-policy-service bot removed this from the 11.0.0 milestone Sep 13, 2025
Copy link
Contributor

Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Android][TimeZoneInfo] GetSystemTimeZones returns timezones leading to duplicate DisplayNames API 21-25
1 participant