Skip to content

[iOS] Fix TimePicker AM/PM frequently changes when the app is closed and reopened#31066

Merged
kubaflo merged 12 commits intodotnet:inflight/currentfrom
devanathan-vaithiyanathan:fix-30837
Mar 5, 2026
Merged

[iOS] Fix TimePicker AM/PM frequently changes when the app is closed and reopened#31066
kubaflo merged 12 commits intodotnet:inflight/currentfrom
devanathan-vaithiyanathan:fix-30837

Conversation

@devanathan-vaithiyanathan
Copy link
Contributor

@devanathan-vaithiyanathan devanathan-vaithiyanathan commented Aug 7, 2025

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Issue Details

The TimePicker was not showing AM/PM correctly after restarting the app when using the format "HH:mm tt".

Description of Change

We now use the same culture for both the display text and the TimePicker control to ensure consistency. When the format includes AM/PM, we use the en-US culture. For 24-hour formats, we use the de-DE culture.

Issues Fixed

Fixes #30837
Fixes #33722

Tested the behavior in the following platforms.

  • Android
  • Windows
  • iOS
  • Mac
Before After
iOS
iOS-Before.mov
iOS
iOS-After.mov

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Aug 7, 2025
@dotnet-policy-service
Copy link
Contributor

Hey there @@devanathan-vaithiyanathan! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Aug 7, 2025
@devanathan-vaithiyanathan devanathan-vaithiyanathan marked this pull request as ready for review August 12, 2025 13:40
Copilot AI review requested due to automatic review settings August 12, 2025 13:40
@devanathan-vaithiyanathan devanathan-vaithiyanathan requested a review from a team as a code owner August 12, 2025 13:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue where the TimePicker on iOS would incorrectly display AM/PM values after restarting the app when using 12-hour time formats. The solution ensures consistent culture usage between the display text and the native iOS picker control.

Key Changes:

  • Refactored culture selection logic to use a consistent culture for both text formatting and picker locale
  • Simplified the culture determination by checking for AM/PM indicators ('t') or 12-hour format ('h') to use en-US culture
  • Added comprehensive UI tests to validate the TimePicker behavior

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Core/src/Platform/iOS/TimePickerExtensions.cs Refactored the UpdateTime method to use consistent culture selection for both text display and picker locale
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30837.cs Added UI test to verify TimePicker format consistency
src/Controls/tests/TestCases.HostApp/Issues/Issue30837.cs Created test page with TimePicker using 12-hour format to reproduce the issue

}

// Apply the same culture to both the text display and the picker
mauiTimePicker.Text = time.ToFormattedString(format ?? string.Empty, formattingCulture);
Copy link

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using string.Empty as fallback when format is null may cause issues. The original code passed format directly to ToFormattedString, which likely handles null formats appropriately. Consider using format directly or verify that ToFormattedString handles empty strings the same way as null.

Suggested change
mauiTimePicker.Text = time.ToFormattedString(format ?? string.Empty, formattingCulture);
mauiTimePicker.Text = time.ToFormattedString(format, formattingCulture);

Copilot uses AI. Check for mistakes.
@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

1 similar comment
@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

1 similar comment
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@jsuarezruiz jsuarezruiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pending snapshots for all the platforms.
image

Already available in the latest build. Could you commit the images?

@devanathan-vaithiyanathan
Copy link
Contributor Author

Pending snapshots for all the platforms. image

Already available in the latest build. Could you commit the images?

@jsuarezruiz , I've added the snapshots

@jsuarezruiz
Copy link
Contributor

jsuarezruiz commented Oct 10, 2025

/azp run MAUI-DeviceTests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jfversluis jfversluis added this to the .NET 10 SR1 milestone Oct 21, 2025
@jfversluis
Copy link
Member

/rebase

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

2 similar comments
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@PureWeen PureWeen modified the milestones: .NET 10 SR1, .NET 10.0 SR2 Nov 4, 2025
@PureWeen PureWeen modified the milestones: .NET 10.0 SR2, .NET 10 SR4 Dec 13, 2025
@PureWeen PureWeen modified the milestones: .NET 10.0 SR4, .NET 10 SR5 Jan 21, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 31066

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 31066"

Copy link
Contributor

@kubaflo kubaflo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Could you please add iOS-26 screenshots?

@kubaflo
Copy link
Contributor

kubaflo commented Mar 3, 2026

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com>
@devanathan-vaithiyanathan
Copy link
Contributor Author

Hi! Could you please add iOS-26 screenshots?

@kubaflo , I have added the iOS 26 snapshot.

@kubaflo kubaflo added the s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates label Mar 4, 2026
Copy link
Contributor

@kubaflo kubaflo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Could you please apply the AI Summary suggestions?

Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com>
@devanathan-vaithiyanathan
Copy link
Contributor Author

Hi! Could you please apply the AI Summary suggestions?

@kubaflo, I have addressed the AI review summary comment

@kubaflo kubaflo added the s/agent-suggestions-implemented Maintainer applies when PR author adopts agent's recommendation label Mar 5, 2026
@kubaflo kubaflo changed the base branch from main to inflight/current March 5, 2026 12:37
@kubaflo kubaflo merged commit 5f2711d into dotnet:inflight/current Mar 5, 2026
5 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-controls-datetimepicker DatePicker, TimePicker community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/ios s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates s/agent-gate-failed AI could not verify tests catch the bug s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) s/agent-suggestions-implemented Maintainer applies when PR author adopts agent's recommendation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Maui 10 iOS TimePicker Strange Characters in place of AM/PM [iOS] TimePicker AM/PM frequently changes when the app is closed and reopened

8 participants