Skip to content

Commit aaaad89

Browse files
Convert only where needed
1 parent 59189ef commit aaaad89

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/TimeZoneNames/TZNames.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,11 @@ public static TimeZoneValues GetNamesForTimeZone(string timeZoneId, string langu
196196
throw new ArgumentException("Invalid Language Code", nameof(languageCode));
197197
}
198198

199+
if (TZConvert.TryWindowsToIana(timeZoneId, out var ianaId))
200+
{
201+
timeZoneId = ianaId;
202+
}
203+
199204
return GetNames(timeZoneId, langKey, false);
200205
}
201206

@@ -212,6 +217,11 @@ public static TimeZoneValues GetAbbreviationsForTimeZone(string timeZoneId, stri
212217
{
213218
throw new ArgumentException("Invalid Language Code", nameof(languageCode));
214219
}
220+
221+
if (TZConvert.TryWindowsToIana(timeZoneId, out var ianaId))
222+
{
223+
timeZoneId = ianaId;
224+
}
215225

216226
return GetNames(timeZoneId, langKey, true);
217227
}
@@ -420,11 +430,6 @@ private static string GetCityName(string timeZoneId, string languageKey)
420430

421431
private static TimeZoneValues GetNames(string timeZoneId, string languageKey, bool abbreviations)
422432
{
423-
if (TZConvert.KnownWindowsTimeZoneIds.Contains(timeZoneId, StringComparer.OrdinalIgnoreCase))
424-
{
425-
timeZoneId = TZConvert.WindowsToIana(timeZoneId);
426-
}
427-
428433
timeZoneId = GetCldrCanonicalId(timeZoneId);
429434
if (timeZoneId == null)
430435
{

0 commit comments

Comments
 (0)