[Windows] TimeZone.current returns GMT despite system settings
Closed this issue · 2 comments
Running TimeZone.current
on Windows always returns GMT despite any present system settings.
This appears to be because on Windows we check TZDEFAULT
:
swift-foundation/Sources/FoundationEssentials/TimeZone/TimeZone_Cache.swift
Lines 116 to 131 in 5141cf6
However, TZDEFAULT
does not appear to be set in the WinSDK
/ucrt
modules so we instead pickup the default value from our CShims:
swift-foundation/Sources/_FoundationCShims/include/_CStdlib.h
Lines 151 to 157 in 5141cf6
These default paths seem unsuitable for Windows and result in us failing to detect the current timezone and falling back to GMT
@compnerd do you happen to know if we'd expect TZDEFAULT
to be defined for Windows somewhere, or do we need to instead do something like what CoreFoundation has historically done: https://github.com/swiftlang/swift-corelibs-foundation/blob/e55e1d88001997be830fbc01086564431d405dad/Sources/CoreFoundation/CFTimeZone.c#L723-L734
I don't expect TZDEFAULT
to be set on Windows, we should be doing what CF did historically here.