-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[iOS] Fix DatePicker to consistently display 4-digit years #31464
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
Conversation
There was a problem hiding this 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 |
|
/rebase |
524b67c to
445d234
Compare
|
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"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Assert.That(currentText, Does.Not.Contain("/24"), | |
| Assert.That(currentText, Does.Contain("2024"), |
StephaneDelcroix
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test failing
|
/rebase |
ab168d0 to
f299fc4
Compare
|
@copilot please create a new pr taking over this pr |
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