Skip to content
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

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

Open
yma44 opened this issue Nov 18, 2024 · 7 comments
Assignees
Labels
area-System.DateTime needs-author-action An issue or pull request that requires more info or actions from the author. os-android
Milestone

Comments

@yma44
Copy link

yma44 commented Nov 18, 2024

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
@mattleibow mattleibow transferred this issue from dotnet/maui Nov 18, 2024
@yma44 yma44 changed the title Taiwanese locale (zh-Hant-TW) does not parse datetime correctly as expected on Android 14+ Taiwanese locale (zh-Hant-TW) does not parse datetime correctly as expected on Android 13+ Nov 20, 2024
@dellis1972
Copy link

@grendello is this us or the runtime team?

@grendello
Copy link
Contributor

grendello commented Nov 21, 2024

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

@grendello grendello assigned steveisok and unassigned grendello Nov 21, 2024
@steveisok steveisok transferred this issue from dotnet/android Nov 21, 2024
@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Nov 21, 2024
@steveisok steveisok added os-android and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Nov 21, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Nov 21, 2024
Copy link
Contributor

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

@steveisok steveisok added area-System.DateTime and removed untriaged New issue has not been triaged by the area owner labels Nov 21, 2024
@steveisok steveisok removed their assignment Nov 21, 2024
Copy link
Contributor

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

@vitek-karas
Copy link
Member

@matouskozak

@matouskozak matouskozak self-assigned this Nov 22, 2024
@matouskozak matouskozak added this to the 10.0.0 milestone Nov 22, 2024
@matouskozak
Copy link
Member

matouskozak commented Nov 22, 2024

@yma44 Thank you for filling the issue. I will need more information to be able to help you resolve the issue.

I tried locally on Android API 33 emulator and I got the expected output: 2024/11/22 下午1:00:00 using:

CultureInfo culture = new CultureInfo("zh-Hant-TW");
CultureInfo.DefaultThreadCurrentCulture = culture;
CultureInfo.DefaultThreadCurrentUICulture = culture;

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

Could you please share more information about your device (API level, ICU version). Also does the issue reproduce on emulators with the same OS version or is it limited to specific physical devices?

@matouskozak matouskozak added the needs-author-action An issue or pull request that requires more info or actions from the author. label Nov 22, 2024
Copy link
Contributor

This issue has been marked needs-author-action and may be missing some important information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.DateTime needs-author-action An issue or pull request that requires more info or actions from the author. os-android
Projects
None yet
Development

No branches or pull requests

6 participants