You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+22Lines changed: 22 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,9 +30,31 @@ A SQL Server 2022 container is started automatically via Testcontainers.
30
30
| Windows and IANA produce same result |`Eastern Standard Time`|`America/New_York`|
31
31
| Invalid time zone name — throws error |_(invalid name)_||
32
32
| IANA time zone when unsupported — throws error ||`America/New_York`|
33
+
| Browser IANA to Windows conversion — same result |_(converted from IANA)_|`America/Chicago`|
34
+
| IANA to Windows ID mapping (C# only, no SQL) | Multiple | Multiple |
33
35
34
36
IANA time zone tests are skipped automatically when the SQL Server instance does not support IANA time zone names.
35
37
36
38
## PostgreSQL Comparison
37
39
38
40
PostgreSQL supports **only IANA time zone names** (e.g. `America/New_York`, `Europe/Berlin`) in its `AT TIME ZONE` clause — Windows time zone names like `Eastern Standard Time` are **not recognized** and will produce an error. You can query `pg_timezone_names` to see supported names.
41
+
42
+
## Browser Time Zone to SQL Server
43
+
44
+
Browsers expose the user's IANA time zone via the [Intl API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/resolvedOptions):
In C#, convert the IANA time zone to a Windows time zone ID for use with SQL Server `AT TIME ZONE`:
52
+
53
+
```csharp
54
+
if (TimeZoneInfo.TryConvertIanaIdToWindowsId(ianaTimeZone, outvarwindowsTimeZone))
55
+
{
56
+
// Use windowsTimeZone with AT TIME ZONE in SQL Server
57
+
}
58
+
```
59
+
60
+
This allows applications to accept IANA time zones from the browser and convert them for SQL Server instances that only support Windows time zone names. SQL Server 2022+ may also accept IANA names directly.
0 commit comments