dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.42k stars 4.76k forks source link

Taiwanese locale (zh-Hant-TW) does not parse datetime correctly as expected on Android 13+ #110044

Open yma44 opened 4 days ago

yma44 commented 4 days ago

Description

We have issue which string with "PM" does not parsed correctly when a device locale is set to Taiwanese (zh-Hant-TW) on Android 13+.
DateTime.TryPase returns true, but output value is not correct. Even though 1PM is passed to the TryParse method, the output is 1am.

This is the code:

DateTime dateTime;
DateTime.TryParse("1:00:00 PM", CultureInfo.CurrentCulture, DateTimeStyles.AssumeLocal, out dateTime);

dateTime variable before calling this method : 0001/1/1 12:00:00 dateTime variable after calling this method : 2024/11/18 1:00:00

If we use Android 12, the output is correct. dateTime variable before calling this method : 0001/1/1 上午12:00:00 dateTime variable after calling this method : 2024/11/18 下午1:00:00

If we use other Chinese locales (e.g. Hong Kong Chinese) there is no issues.

I am using Microsoft Visual Studio Enterprise 2022 (64-bit) - Current Version 17.8.1, but also tried Microsoft Visual Studio Enterprise 2022 (64-bit) - Preview Version 17.11.0 Preview 2.1, still got the same issue.

These are the full details of VS.

Microsoft Visual Studio Enterprise 2022
Version 17.8.1
VisualStudio.17.Release/17.8.1+34316.72
Microsoft .NET Framework
Version 4.8.09032

Installed Version: Enterprise

ASP.NET and Web Tools   17.8.352.38654
ASP.NET and Web Tools

Azure App Service Tools v3.0.0   17.8.352.38654
Azure App Service Tools v3.0.0

Azure Functions and Web Jobs Tools   17.8.352.38654
Azure Functions and Web Jobs Tools

C# Tools   4.8.0-7.23558.1+e091728607ca0fc9efca55ccfb3e59259c6b5a0a
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.4.39 (main@e8108eb)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

Microsoft Azure Tools for Visual Studio   2.9
Support for Azure Cloud Services projects

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.8.17 (957fbed)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager   6.8.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

Razor (ASP.NET Core)   17.8.3.2353105+f0a326f3e15b2370371693a76fd379635387c74d
Provides languages services for ASP.NET Core Razor.

SQL Server Data Tools   17.8.119.0
Microsoft SQL Server Data Tools

TypeScript Tools   17.0.20920.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   4.8.0-7.23558.1+e091728607ca0fc9efca55ccfb3e59259c6b5a0a
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.8.0-beta.23475.2+10f956e631a1efc0f7f5e49c626c494cd32b1f50
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.8.0.155 (d17-8@7042beb)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer   17.8.3.6 (remotes/origin/d17-8@eccf46a291)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates   17.8.16 (830b56a)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK   13.2.2.0 (d17-5/45b0e14)
Xamarin.Android Reference Assemblies and MSBuild support.
    Mono: d9a6e87
    Java.Interop: xamarin/java.interop/d17-5@149d70fe
    SQLite: xamarin/sqlite/3.40.1@68c69d8
    Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-5@ca1552d

Xamarin.iOS and Xamarin.Mac SDK   16.4.0.23 (9defd91b3)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

Unknown/Other

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 14 and above.

Did you find any workaround?

No response

Relevant log output

[monodroid-assembly] open_from_bundles: failed to load assembly zh-Hant-TW/System.Private.CoreLib.resources.dll
[monodroid-assembly] open_from_bundles: failed to load assembly zh-Hant-TW/System.Private.CoreLib.resources.dll
[monodroid-assembly] open_from_bundles: failed to load assembly zh-Hant/System.Private.CoreLib.resources.dll
[monodroid-assembly] open_from_bundles: failed to load assembly zh-Hant/System.Private.CoreLib.resources.dll
[monodroid-assembly] open_from_bundles: failed to load assembly zh/System.Private.CoreLib.resources.dll
[monodroid-assembly] open_from_bundles: failed to load assembly zh/System.Private.CoreLib.resources.dll
dellis1972 commented 2 days ago

@grendello is this us or the runtime team?

grendello commented 1 day ago

@dellis1972 it's the runtime team, we no longer have any TZ-specific code in our repo

dotnet-policy-service[bot] commented 1 day ago

Tagging subscribers to 'arch-android': @vitek-karas, @simonrozsival, @steveisok, @akoeplinger See info in area-owners.md if you want to be subscribed.

dotnet-policy-service[bot] commented 1 day ago

Tagging subscribers to this area: @dotnet/area-system-datetime See info in area-owners.md if you want to be subscribed.

vitek-karas commented 1 day ago

@matouskozak