Skip to content

Conversation

@jsuarezruiz
Copy link
Contributor

Description of Change

The issue occurred in DatePickerExtensions.cs in the UpdateDate method. When using the default date format (null, empty, or "d"), the code uses NSDateFormatterStyle.Short which defaults to 2-digit year patterns on iOS. After user interaction triggers date updates, this causes inconsistent year display.

This PR apply changes to apply a regex replacement to convert 2-digit years to 4-digit years. The regex safely avoids modifying already-correct 4-digit year patterns.

Added comprehensive test coverage with device and ui tests.

Issues Fixed

Fixes #31167

@jsuarezruiz jsuarezruiz added the t/bug Something isn't working label Sep 3, 2025
Copilot AI review requested due to automatic review settings September 3, 2025 10:24
@jsuarezruiz jsuarezruiz requested a review from a team as a code owner September 3, 2025 10:24
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 iOS DatePicker issue where 4-digit years would inconsistently display as 2-digit years after user interaction. The fix applies a regex replacement to convert 2-digit year patterns to 4-digit patterns in the date format string when using default or short date formats.

Key changes:

  • Modified date formatting logic to ensure consistent 4-digit year display
  • Added comprehensive test coverage for various date format scenarios
  • Created UI tests to validate the fix through user interaction scenarios

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Core/src/Platform/iOS/DatePickerExtensions.cs Implements regex-based fix to convert 2-digit to 4-digit year patterns in date format strings
src/Core/tests/DeviceTests/Handlers/DatePicker/DatePickerHandlerTests.iOS.cs Adds extensive device tests covering various date format scenarios and edge cases
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31117.cs Creates comprehensive UI tests to validate 4-digit year consistency through user interactions
src/Controls/tests/TestCases.HostApp/Issues/Issues31117.xaml Provides XAML UI for automated testing with proper AutomationId attributes
src/Controls/tests/TestCases.HostApp/Issues/Issues31117.xaml.cs Implements code-behind for the test UI page with date manipulation functionality

@PureWeen PureWeen added this to the .NET 10.0 GA milestone Oct 6, 2025
@PureWeen PureWeen moved this from Todo to Ready To Review in MAUI SDK Ongoing Oct 10, 2025
rmarinho
rmarinho previously approved these changes Oct 13, 2025
@github-project-automation github-project-automation bot moved this from Ready To Review to Approved in MAUI SDK Ongoing Oct 13, 2025
@rmarinho
Copy link
Member

/rebase

@StephaneDelcroix
Copy link
Contributor

DatePicker should not show 2-digit year pattern Assert.That(datePickerText, Does.Not.Contain("/24")) Expected: not String containing "/24" But was: "12/24/2024"

the code looks correct, but the test looks wrong

var currentText = App.WaitForElement("MyDatePicker").GetText();
Assert.That(currentText, Does.Contain("2024"),
$"After interaction #{i + 1}, should still show 4-digit year");
Assert.That(currentText, Does.Not.Contain("/24"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Assert.That(currentText, Does.Not.Contain("/24"),
Assert.That(currentText, Does.Contain("2024"),

Copy link
Contributor

@StephaneDelcroix StephaneDelcroix left a comment

Choose a reason for hiding this comment

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

test failing

@github-project-automation github-project-automation bot moved this from Approved to Changes Requested in MAUI SDK Ongoing Oct 15, 2025
@rmarinho
Copy link
Member

/rebase

@PureWeen
Copy link
Member

PureWeen commented Nov 7, 2025

@copilot please create a new pr taking over this pr

Copy link
Contributor

Copilot AI commented Nov 7, 2025

@PureWeen I've opened a new pull request, #32451, to work on those changes. Once the pull request is ready, I'll request review from you.

@PureWeen
Copy link
Member

PureWeen commented Nov 7, 2025

#32451

@PureWeen PureWeen closed this Nov 7, 2025
@github-project-automation github-project-automation bot moved this from Changes Requested to Done in MAUI SDK Ongoing Nov 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-controls-datetimepicker DatePicker, TimePicker platform/ios t/bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[iOS] DatePicker initially shows year in 4 digits, but after changing the year it displays only 2 digits in net 10.0

5 participants