|
1 | 1 | using System; |
2 | | -using System.Reflection; |
| 2 | +using System.Collections.Generic; |
3 | 3 |
|
4 | 4 | namespace NetCoreForce.Client.Tests |
5 | | -{ |
| 5 | +{ |
6 | 6 | /// <summary> |
7 | | - /// Sample TimeZone IDs for use in tests |
| 7 | + /// Sample TimeZone IDs for use in tests. |
| 8 | + /// Windows and Linux/macOS use different TimeZoneInfo ID formats (Windows-native vs IANA), |
| 9 | + /// so the appropriate ID for the current OS is exposed here. |
8 | 10 | /// </summary> |
9 | 11 | public static class TimeZoneIds |
10 | 12 | { |
11 | | - public static string TimeZoneIdNewYork = "America/New_York"; |
12 | | - public static string TimeZoneIdPhoenix = "America/Phoenix"; |
13 | | - public static string TimeZoneIdLondon = "Europe/London"; |
14 | | - public static string TimeZoneIdTokyo = "Asia/Tokyo"; |
| 13 | + private static readonly bool IsWindows = Environment.OSVersion.Platform == PlatformID.Win32NT; |
| 14 | + |
| 15 | + public static string NewYork => IsWindows ? "Eastern Standard Time" : "America/New_York"; |
| 16 | + public static string Phoenix => IsWindows ? "US Mountain Standard Time" : "America/Phoenix"; // no DST |
| 17 | + public static string London => IsWindows ? "GMT Standard Time" : "Europe/London"; |
| 18 | + public static string Tokyo => IsWindows ? "Tokyo Standard Time" : "Asia/Tokyo"; |
| 19 | + public static string Kathmandu => IsWindows ? "Nepal Standard Time" : "Asia/Kathmandu"; // UTC+5:45 |
| 20 | + public static string Auckland => IsWindows ? "New Zealand Standard Time" : "Pacific/Auckland"; |
| 21 | + public static string Moscow => IsWindows ? "Russian Standard Time" : "Europe/Moscow"; |
| 22 | + public static string Shanghai => IsWindows ? "China Standard Time" : "Asia/Shanghai"; |
| 23 | + |
| 24 | + public static IEnumerable<string> All => new[] |
| 25 | + { |
| 26 | + NewYork, Phoenix, London, Tokyo, Kathmandu, Auckland, Moscow, Shanghai |
| 27 | + }; |
15 | 28 | } |
16 | 29 | } |
0 commit comments