-
Notifications
You must be signed in to change notification settings - Fork 861
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows local time zone should be mapped into WSL properly #3747
Comments
A few cases: |
Note, #3109 describes how the MSFT zone shows up on .NET Core:
Again, if mapped correctly, these APIs would just work. |
Thanks for the detailed post, @mj1856. Agreed, this is something that should be revisited. |
Thanks for filing this issue! |
@jefgen - Thanks! I didn't know about that one. |
Everybody take note-- this is how your make issues :) |
The new implementation is in 18344, I hope it ticks all the boxes for you :) |
Thanks! I'll take a look at some point. ;) |
Hi, it seems like the fix for this breaks things for people using utc on windows (dual booters), which can be done with a registry key like so
I'm not even sure if the above is something officially supported, but with windows set to utc wsl2 still runs the conversion from localtime, meaning my clock ends up 7 hours fast. |
@chetgurevitch, could you please open a separate issue for that problem so it doesn't get lost? Thanks. |
RealTimeIsUniversal refers only to the RTC setting being UTC rather than local, and should have no influence on Windows timekeeping after boot, and should make it easier as WSL RTC virtualization should not have to backconvert to UTC at Unix boot. |
As touched on in #856, #1392, and #3109 (without resolution), WSL doesn't correctly map the local time zone of Windows into Linux. Instead, LsxxManager creates a pseudo time zone in
/usr/share/zoneinfo/Msft/localtime
, and hard links it to/etc/localtime
.This approach is problematic. Though it gets the current time correct, it removes a ton of detail about the time zone, such as its identifier, abbreviations, historical and future transitions (if they deviate from those in the current year), etc. It also removes any ability for downstream APIs (such as ICU) to generate a correct display name.
This is seen in many environments, but perhaps the easiest is in Node JS. Install the latest Node LTS (I'm on 10.15.0) into a regular (non-WSL) Windows environment and also into WSL. Then in the Node command line:
In a regular environment, with my computer's time zone set for US Pacific Time, I get:
In a WSL environment (for me, Ubuntu 18.04.1 LTS), I get:
It can also be seen just on the Linux command line:
For me running this in December, it should return
PST
, but in WSL it returnsSTD
because that is the abbreviation assigned in the pseudo zone.Additionally - the pseudo zone is not necessary. Windows already has the ability to generate the Linux (IANA) time zone identifier, via either of two mechanisms:
Call the WinRT/UWP function:
Windows::Globalization::Calendar().GetTimeZone()
(docs here)The above function uses the data file at
%WINDIR%\Globalization\Time Zone\timezoneMapping.xml
. It can be used directly if WinRT/UWP is not available. The entry to use is the one withRegion="001"
and aWinID
corresponding to the output fromGetDynamicTimeZoneInformation->TimeZoneKeyName
(or from the registry atHKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation\TimeZoneKeyName
). The Linux time zone ID is in theTZID
field.Once the Linux time zone ID is known, then
/etc/localtime
should simply be symlinked to the corresponding file in/usr/share/zoneinfo
. If it doesn't exist (perhaps on certain versions of Linux without a tzdata distribution), then and only then should it fall back to the pseudoMsft
time zone.Please revisit this asap. Thanks.
(I can be reached internally at ms alias
mattjoh
if you have any additional questions)The text was updated successfully, but these errors were encountered: