Skip to content

Time Zone IANA Ids to/From Windows Ids conversion APIs #49407

@tarekgh

Description

@tarekgh

Background and Motivation

It is planned in 6.0 release to start supporting the IANA time zone Ids on Windows and support Windows Ids on non-Windows platforms (e.g. Linux). That will allow users to use any time zone Id across all platforms without worrying what Id work on what platform.
In addition to that, users need to be able to convert any Windows Id to IANA Id and vice versa. The proposal here is to provide the needed APIs to do that.

As we are using ICU library for supporting IANA Ids and the conversion, we'll be limited to provide this functionality only when running with ICU. i.e. this functionality is not going to be supported in the Globalization Invariant mode nor when enabling NLS mode on Windows. Because of this limitation, the proposed APIs is using TryConvert pattern to allow users check for the conversion failures without throwing any exception.

Proposed API

namespace System
{
    public sealed partial class TimeZoneInfo : IEquatable<TimeZoneInfo?>, ISerializable, IDeserializationCallback
    {
        // Tells if the current TimeZoneInfo Id is Iana Id or not.
        public readonly bool HasIanaId { get; }

        // Try to convert from Iana Id to Windows Id.
        public static bool TryConvertIanaIdToWindowsId(string ianaId, out string windowsId);

        // Try to convert from Windows Id to Iana Id.
        public static bool TryConvertWindowsIdToIanaId(string windowsId, out string ianaId);
        public static bool TryConvertWindowsIdToIanaId(string windowsId, string region, out string ianaId);
    }
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions