-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
net6-ios: DateTimeOffset.Local does not have local timezone #69492
Comments
From @dotMorten on Tue, 17 May 2022 22:50:02 GMT @spouliot theorized here that this might be an issue: xamarin/xamarin-macios#14740 (comment) |
From @spouliot on Tue, 17 May 2022 22:53:26 GMT hmm... did I theorized or terrorized ? 🦖 |
From @dotMorten on Tue, 17 May 2022 23:37:37 GMT @spouliot well you didn't follow up on your hunch so... 🔥 😁 |
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
From @spouliot on Tue, 17 May 2022 23:51:08 GMT I knew it 🦖 would bite me soon enough 😈 |
From @rolfbjarne on Wed, 18 May 2022 13:30:23 GMT I can reproduce this on:
I can not reproduce this on:
|
From @rolfbjarne on Wed, 18 May 2022 13:32:44 GMT This is not a duplicate of xamarin/xamarin-macios#14740, because setting |
@dalexsoto FYI this might be an important bug/fix to get out asap. |
can you try setting the |
Tagging subscribers to this area: @dotnet/area-system-runtime Issue DetailsFrom @dotMorten on Tue, 17 May 2022 22:49:14 GMT Steps to Reproduce
Note: This does not reproduce with legacy Xamarin.iOS on the same device. I can't think of a workaround, and this bug could lead to some major data input/output issues. Due to the data-corruption issues this could cause (people missing their flights, invalid data getting entered and bad decisions made because of it etc), I'd consider something like this a showstopper. Expected BehaviorDateTime/DateTimeOffset APIs understands the local timezone Actual BehaviorTime zone not set Environment.NET 6.0.300, VS2022 17.3p1, .NET MAUI RC3. iOS 14 Version information``` Microsoft Visual Studio Enterprise 2022 Version 17.2.0 Preview 6.0 VisualStudio.17.Preview/17.2.0-pre.6.0+32427.441 Microsoft .NET Framework Version 4.8.04084Installed Version: Enterprise Visual C++ 2022 00476-80000-00000-AA015 ASP.NET and Web Tools 2019 17.2.386.48104 Azure App Service Tools v3.0.0 17.2.386.48104 C# Tools 4.2.0-4.22220.5+432d17a83aa5623e4581756f4d642997048056bd Common Azure Tools 1.10 Extensibility Message Bus 1.2.6 (master@34d6af2) Microsoft JVM Debugger 1.0 Mono Debugging for Visual Studio 17.2.20 (482eb2a) NuGet Package Manager 6.2.0 Razor (ASP.NET Core) 17.0.0.2218101+885a343b00bcab620a90c1550c37dafd730ce984 SQL Server Data Tools 17.0.62204.01010 Syntax Visualizer 1.0 Test Adapter for Boost.Test 1.0 Test Adapter for Google Test 1.0 TypeScript Tools 17.0.10418.2001 Visual Basic Tools 4.2.0-4.22220.5+432d17a83aa5623e4581756f4d642997048056bd Visual F# Tools 17.1.0-beta.22178.3+6da0245a7ce4bb8483b8d1f2993c8ecaea967ad9 Visual Studio IntelliCode 2.2 VisualStudio.DeviceLog 1.0 VisualStudio.Mac 1.0 VSPackage Extension 1.0 Xamarin 17.2.0.171 (d17-2@7554231) Xamarin Designer 17.2.0.244 (remotes/origin/d17-2@197e1a0b7) Xamarin Templates 17.2.15 (2e3b60e) Xamarin.Android SDK 12.3.0.3 (d17-2/bbba5a2) Xamarin.iOS and Xamarin.Mac SDK 15.10.0.1 (568bdb24e)
|
Tagging subscribers to 'os-ios': @steveisok, @akoeplinger Issue DetailsFrom @dotMorten on Tue, 17 May 2022 22:49:14 GMT Steps to Reproduce
Note: This does not reproduce with legacy Xamarin.iOS on the same device. I can't think of a workaround, and this bug could lead to some major data input/output issues. Due to the data-corruption issues this could cause (people missing their flights, invalid data getting entered and bad decisions made because of it etc), I'd consider something like this a showstopper. Expected BehaviorDateTime/DateTimeOffset APIs understands the local timezone Actual BehaviorTime zone not set Environment.NET 6.0.300, VS2022 17.3p1, .NET MAUI RC3. iOS 14 Version information``` Microsoft Visual Studio Enterprise 2022 Version 17.2.0 Preview 6.0 VisualStudio.17.Preview/17.2.0-pre.6.0+32427.441 Microsoft .NET Framework Version 4.8.04084Installed Version: Enterprise Visual C++ 2022 00476-80000-00000-AA015 ASP.NET and Web Tools 2019 17.2.386.48104 Azure App Service Tools v3.0.0 17.2.386.48104 C# Tools 4.2.0-4.22220.5+432d17a83aa5623e4581756f4d642997048056bd Common Azure Tools 1.10 Extensibility Message Bus 1.2.6 (master@34d6af2) Microsoft JVM Debugger 1.0 Mono Debugging for Visual Studio 17.2.20 (482eb2a) NuGet Package Manager 6.2.0 Razor (ASP.NET Core) 17.0.0.2218101+885a343b00bcab620a90c1550c37dafd730ce984 SQL Server Data Tools 17.0.62204.01010 Syntax Visualizer 1.0 Test Adapter for Boost.Test 1.0 Test Adapter for Google Test 1.0 TypeScript Tools 17.0.10418.2001 Visual Basic Tools 4.2.0-4.22220.5+432d17a83aa5623e4581756f4d642997048056bd Visual F# Tools 17.1.0-beta.22178.3+6da0245a7ce4bb8483b8d1f2993c8ecaea967ad9 Visual Studio IntelliCode 2.2 VisualStudio.DeviceLog 1.0 VisualStudio.Mac 1.0 VSPackage Extension 1.0 Xamarin 17.2.0.171 (d17-2@7554231) Xamarin Designer 17.2.0.244 (remotes/origin/d17-2@197e1a0b7) Xamarin Templates 17.2.15 (2e3b60e) Xamarin.Android SDK 12.3.0.3 (d17-2/bbba5a2) Xamarin.iOS and Xamarin.Mac SDK 15.10.0.1 (568bdb24e)
|
Yeah, that worked. |
How do you do that? I could use the workaround for now just to get my tests to pass again |
Looks like this does it: Environment.SetEnvironmentVariable ("TZ", "Europe/Paris");
TimeZoneInfo.ClearCachedData (); |
Looks like we purposefully use UTC if we can't figure out the local time zone. runtime/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.NonAndroid.cs Lines 404 to 408 in 2291ac9
We'll need to instead grab the local time zone name off of the device. |
Fixed by #70149 |
From @dotMorten on Tue, 17 May 2022 22:49:14 GMT
Steps to Reproduce
DateTimeOffset.Now
andDateTimeOffset.UtcNow
and notice they are the same.DateTimeOffset.UtcNow.ToLocalTime()
has no real effect, since it thinks that is already the local timezone.DateTimeOffset.Parse("12/30/1997 10:00:00 PM +00:00").ToLocal()
fails to convert this UTC timestamp to local time zone.Debug.WriteLine($"UTC: {DateTimeOffset.UtcNow}\nLocal: {DateTimeOffset.Now}\nLocal Converted: {DateTimeOffset.UtcNow.ToLocalTime())
; prints the same timestamp each time.Note: This does not reproduce with legacy Xamarin.iOS on the same device.
I can't think of a workaround, and this bug could lead to some major data input/output issues. Due to the data-corruption issues this could cause (people missing their flights, invalid data getting entered and bad decisions made because of it etc), I'd consider something like this a showstopper.
Expected Behavior
DateTime/DateTimeOffset APIs understands the local timezone
Actual Behavior
Time zone not set
Environment
.NET 6.0.300, VS2022 17.3p1, .NET MAUI RC3. iOS 14
Version information
``` Microsoft Visual Studio Enterprise 2022 Version 17.2.0 Preview 6.0 VisualStudio.17.Preview/17.2.0-pre.6.0+32427.441 Microsoft .NET Framework Version 4.8.04084Installed Version: Enterprise
Visual C++ 2022 00476-80000-00000-AA015
Microsoft Visual C++ 2022
ASP.NET and Web Tools 2019 17.2.386.48104
ASP.NET and Web Tools 2019
Azure App Service Tools v3.0.0 17.2.386.48104
Azure App Service Tools v3.0.0
C# Tools 4.2.0-4.22220.5+432d17a83aa5623e4581756f4d642997048056bd
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
Extensibility Message Bus 1.2.6 (master@34d6af2)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.
Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
Mono Debugging for Visual Studio 17.2.20 (482eb2a)
Support for debugging Mono processes with Visual Studio.
NuGet Package Manager 6.2.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/
Razor (ASP.NET Core) 17.0.0.2218101+885a343b00bcab620a90c1550c37dafd730ce984
Provides languages services for ASP.NET Core Razor.
SQL Server Data Tools 17.0.62204.01010
Microsoft SQL Server Data Tools
Syntax Visualizer 1.0
An extension for visualizing Roslyn SyntaxTrees.
Test Adapter for Boost.Test 1.0
Enables Visual Studio's testing tools with unit tests written for Boost.Test. The use terms and Third Party Notices are available in the extension installation directory.
Test Adapter for Google Test 1.0
Enables Visual Studio's testing tools with unit tests written for Google Test. The use terms and Third Party Notices are available in the extension installation directory.
TypeScript Tools 17.0.10418.2001
TypeScript Tools for Microsoft Visual Studio
Visual Basic Tools 4.2.0-4.22220.5+432d17a83aa5623e4581756f4d642997048056bd
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Visual F# Tools 17.1.0-beta.22178.3+6da0245a7ce4bb8483b8d1f2993c8ecaea967ad9
Microsoft Visual F# Tools
Visual Studio IntelliCode 2.2
AI-assisted development for Visual Studio.
VisualStudio.DeviceLog 1.0
Information about my package
VisualStudio.Mac 1.0
Mac Extension for Visual Studio
VSPackage Extension 1.0
VSPackage Visual Studio Extension Detailed Info
Xamarin 17.2.0.171 (d17-2@7554231)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.
Xamarin Designer 17.2.0.244 (remotes/origin/d17-2@197e1a0b7)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.
Xamarin Templates 17.2.15 (2e3b60e)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.
Xamarin.Android SDK 12.3.0.3 (d17-2/bbba5a2)
Xamarin.Android Reference Assemblies and MSBuild support.
Mono: adf1bc4
Java.Interop: xamarin/java.interop/d17-2@9760f0a9
ProGuard: Guardsquare/proguard@912d149
SQLite: xamarin/sqlite@7b1e016
Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-2@fc3c2ac
Xamarin.iOS and Xamarin.Mac SDK 15.10.0.1 (568bdb24e)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
The text was updated successfully, but these errors were encountered: