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

bug: ion-datetime displays 0:00 pm on phone chromium browsers #25862

Closed
4 of 7 tasks
JoeBoxr opened this issue Aug 31, 2022 · 11 comments · Fixed by #25869
Closed
4 of 7 tasks

bug: ion-datetime displays 0:00 pm on phone chromium browsers #25862

JoeBoxr opened this issue Aug 31, 2022 · 11 comments · Fixed by #25869
Labels
bug: external Bugs in non-Ionic software that impact Ionic apps (I.e. WebKit, Angular, Android etc) type: bug a confirmed bug report

Comments

@JoeBoxr
Copy link

JoeBoxr commented Aug 31, 2022

Prerequisites

Ionic Framework Version

  • v4.x
  • v5.x
  • v6.x
  • Nightly

Current Behavior

When selecting the time on the datetime popup and setting 12:00 pm, the resulting value in datetime component is 0:00 pm. This only occurs on phone devices (Android version 12 for this test) running chromium browser (chrome, edge etc.). It works as expected with Firefox on mobile.

Expected Behavior

It's expected that 12:00 pm selected in the time popup results in a 12:00 pm value in datetime component.

Steps to Reproduce

Use the following code in a mobile (Android 12) web app.

<ion-datetime-button datetime="openTime"></ion-datetime-button> <ion-modal [keepContentsMounted]="true"> <ng-template> <ion-datetime hourCycle="h12" id="openTime" presentation="time" showDefaultButtons="true" doneText="Ok"></ion-datetime> </ng-template> </ion-modal>
time-bug

Code Reproduction URL

https://angular-ivy-ptcjwe.stackblitz.io

Ionic Info

Ionic:

Ionic CLI : 5.4.4 (C:\Users\Admin\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : @ionic/angular 6.2.4
@angular-devkit/build-angular : 13.3.3
@angular-devkit/schematics : 13.2.6
@angular/cli : 13.3.3
@ionic/angular-toolkit : 6.1.0

Utility:

cordova-res : not installed
native-run : not installed

System:

NodeJS : v14.17.0 (C:\Program Files\nodejs\node.exe)
npm : 6.14.13
OS : Windows 10

Additional Information

No response

@ionitron-bot ionitron-bot bot added the triage label Aug 31, 2022
@liamdebeasi liamdebeasi self-assigned this Aug 31, 2022
@liamdebeasi
Copy link
Contributor

Thanks for the report. What version of Chrome are you testing this on? I am testing this on Chrome 104 on Android 13 and am unable to reproduce this issue. The datetime button renders "12:00 PM" as expected.

@liamdebeasi liamdebeasi added the needs: reply the issue needs a response from the user label Aug 31, 2022
@liamdebeasi liamdebeasi removed their assignment Aug 31, 2022
@ionitron-bot ionitron-bot bot removed the triage label Aug 31, 2022
@JoeBoxr
Copy link
Author

JoeBoxr commented Aug 31, 2022

Hello.

It's on Android 12 running Chrome 104 and Chrome dev 106

@ionitron-bot ionitron-bot bot added triage and removed needs: reply the issue needs a response from the user labels Aug 31, 2022
@liamdebeasi
Copy link
Contributor

liamdebeasi commented Aug 31, 2022

Do you have any additional information that could help me reproduce the issue? Also what device are you testing this on?

I see the text being rendered as "12:00 PM" on a Pixel 4a:

@liamdebeasi liamdebeasi added the needs: reply the issue needs a response from the user label Aug 31, 2022
@ionitron-bot ionitron-bot bot removed the triage label Aug 31, 2022
@JoeBoxr
Copy link
Author

JoeBoxr commented Aug 31, 2022

Shows up fine on a tablet running Android 11 and a phone running Android 6. Seems to be isolated to just Android 12

@ionitron-bot ionitron-bot bot added triage and removed needs: reply the issue needs a response from the user labels Aug 31, 2022
@JoeBoxr
Copy link
Author

JoeBoxr commented Aug 31, 2022

The Android 12 device I'm using is running OnePlus OxygenOS which may be the underlining problem to this issue

@liamdebeasi
Copy link
Contributor

Thanks for the additional information. What is the locale being used on your device? You can find this by logging navigator.language when inspecting the app using Chrome developer tools.

@JoeBoxr
Copy link
Author

JoeBoxr commented Aug 31, 2022

Hello.

For some reason it's showing up as en-GB on this device when it should be en-US. This is obviously an OS issue and thank you for your time looking into this.

@liamdebeasi
Copy link
Contributor

Thanks! Setting the locale to en-GB is what triggered the issue for me. I can confirm that this is a bug.

Ionic uses Intl.DateTimeFormat to handle most of the date and time localization. One of the options we use here is hour12 which lets us control whether to show the time in a 12 hour or 24 hour format.

It looks like there is a bug in Chromium-based browsers (Chrome, Edge, Brave, etc) where "12:00 pm" is incorrectly rendered as "0:00 pm" even when setting hour12: true: https://bugs.chromium.org/p/chromium/issues/detail?id=1347316&q=hour12&can=2. Using the hourCycle option instead seems to resolve the issue. We should probably use this anyways since it will make supporting #23750 easier.

@liamdebeasi liamdebeasi added type: bug a confirmed bug report bug: external Bugs in non-Ionic software that impact Ionic apps (I.e. WebKit, Angular, Android etc) labels Aug 31, 2022
@ionitron-bot ionitron-bot bot removed the triage label Aug 31, 2022
@liamdebeasi
Copy link
Contributor

Here is a dev build if you would like to test the proposed fix:

npm install @ionic/[email protected]

You may need to install this to a local application as StackBlitz sometimes has trouble installing dev builds.

@liamdebeasi
Copy link
Contributor

Thanks for the issue. This has been resolved via #25869, and a fix will be available in an upcoming release of Ionic Framework. Please feel free to continue testing the dev build.

@ionitron-bot
Copy link

ionitron-bot bot commented Oct 6, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Oct 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug: external Bugs in non-Ionic software that impact Ionic apps (I.e. WebKit, Angular, Android etc) type: bug a confirmed bug report
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants