-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
new trimmer feature System.TimeZoneInfo.Invariant #111215
Conversation
Tagging subscribers to this area: @dotnet/area-system-globalization |
Will it be acceptable to have |
It will report UTC. Also this behavior already existed before this PR, here I'm just removing the ability to load TZ data from file system, when |
Thanks. I am not sure my question is answered :-) I am not questioning the PR more than questioning behavior. I guess users haven't run into this yet to report it. Returning UTC time when having TZ settings different than UTC is questionable. Maybe it is acceptable to the browser (especially servers) but wanted to know how we validated this assumption. |
src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets
Outdated
Show resolved
Hide resolved
This is not how it works. You would not be able to change to non-UTC timezone. Let me show you: given code Console.WriteLine($"TimeZoneInfo.Local is {TimeZoneInfo.Local}");
Console.WriteLine($"DateTime.UtcNow is {DateTime.UtcNow}");
Console.WriteLine($"DateTime.Now is {DateTime.Now}");
var start = DateTime.UtcNow;
var timezonesCount = TimeZoneInfo.GetSystemTimeZones().Count;
await Delay(100);
var end = DateTime.UtcNow;
Console.WriteLine($"Found {timezonesCount} timezones in the TZ database in {end - start}");
TimeZoneInfo utc = TimeZoneInfo.FindSystemTimeZoneById("UTC");
Console.WriteLine($"{utc.DisplayName} BaseUtcOffset is {utc.BaseUtcOffset}");
try
{
TimeZoneInfo tst = TimeZoneInfo.FindSystemTimeZoneById("Asia/Tokyo");
Console.WriteLine($"{tst.DisplayName} BaseUtcOffset is {tst.BaseUtcOffset}");
}
catch (TimeZoneNotFoundException tznfe)
{
Console.WriteLine($"Could not find Asia/Tokyo: {tznfe.Message}");
} At 12:19 in Prague, you will get following output
|
The On the browser "operating system" we don't have TZ database pre-installed and so we are bundling it with each application. It's 300KB of download and some CPU time before the runtime can start. That's a lot for a web app, especially if your business logic is not about dates/times/calendars. Before this PR the I feel quite safe to make this change for the browser target. @steveisok is this how it works for iOS too ? Can I assume people are not shipping custom |
We don't ship anything custom on iOS or Android as we rely on whatever they do. |
b5ce502
to
48ccc77
Compare
# Conflicts: # src/libraries/System.Runtime/tests/System.Runtime.Tests/System/TimeZoneInfoTests.cs
src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.Android.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.NonAndroid.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Win32.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Win32.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Win32.cs
Outdated
Show resolved
Hide resolved
…in32.cs Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
…in32.cs Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
…in32.cs Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
…nix.NonAndroid.cs Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
@sbomer @MichalStrehovsky @tarekgh do you have further questions or feedback ? |
src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.Android.cs
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.NonAndroid.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.NonAndroid.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @pavelsavara
I added a few minor comments. LGTM otherwise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
...e/tests/System.Runtime.Tests/InvariantTimezone/System.Runtime.InvariantTimezone.Tests.csproj
Outdated
Show resolved
Hide resolved
/ba-g CI timeouts |
* main: (31 commits) Fix linux-x86 build (dotnet#111861) Add FrozenDictionary specialization for integers / enums (dotnet#111886) [SRM] Refactor reading from streams. (dotnet#111323) Sign the DAC and DBI during the build process instead of in separate steps (dotnet#111416) Removing Entry2MethodDesc as it is unnecessary (dotnet#111756) Cross Product for Vector2 and Vector4 (dotnet#111265) Handle unicode in absolute URI path for combine. (dotnet#111710) Drop RequiresProcessIsolation on mcc tests (dotnet#111887) [main] Update dependencies from dotnet/roslyn (dotnet#111691) new trimmer feature System.TimeZoneInfo.Invariant (dotnet#111215) [browser] reduce msbuild memory footprint (dotnet#111751) Add debugging checks for stack overflow tests failure (dotnet#111867) Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2629821 (dotnet#111884) Bump main to preview2 (dotnet#111882) Avoid generic virtual dispatch for frozen collections alternate lookup (dotnet#108732) Bump main versioning to preview1 (dotnet#111880) Switch OneLoc to main (dotnet#111872) Improve docs on building ILVerify (dotnet#111851) Update Debian version to 13 (dotnet#111768) win32: add fallback to environment vars for system folder (dotnet#109673) ...
Motivation: when
TryGetLocalTzFile
is included it brings dependency toSystem.IO.File
and its dependencies.System.TimeZoneInfo.Invariant
triggered by existing<InvariantTimezone>true</InvariantTimezone>
System.TimeZoneInfo.Invariant
getter also driven byDOTNET_SYSTEM_TIMEZONE_INVARIANT
env variableILLink.Substitutions.LegacyJsInterop.xml
Together with dotnet/sdk#45792
<InvariantTimezone>true</InvariantTimezone>
is pre-existing feature.After discussion below the implementation was unified to other platforms.
Explanation of the feature in comment below.