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

[WinUI] Fix DateTimeFormatter for "ddd" #20045

Merged
merged 2 commits into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Compatibility/Core/src/Windows/DatePickerRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void UpdateDay()
if (day == 0)
Control.DayVisible = false;
else if (day == 3)
Control.DayFormat = "day dayofweek.abbreviated";
Control.DayFormat = "dayofweek.abbreviated";
else if (day == 4)
Control.DayFormat = "dayofweek.full";
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ internal static string GetDayFormat(string format)
var day = format.Count(x => x == 'd');

if (day == 3)
return "{day.integer} {dayofweek.abbreviated}";
return "{dayofweek.abbreviated}";
else if (day == 4)
return "{dayofweek.full}";
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public override async Task DisconnectHandlerDoesntCrash()
[Theory(DisplayName = "Format Initializes Correctly")]
[InlineData("dd/MM/yyyy", "{day.integer(2)}/{month.integer(2)}/{year.full}")]
[InlineData("d/M/yy", "{day.integer}/{month.integer(1)}/{year.abbreviated}")]
[InlineData("ddd/MMM/yyyy", "{day.integer} {dayofweek.abbreviated}/{month.abbreviated}/{year.full}")]
[InlineData("ddd/MMM/yyyy", "{dayofweek.abbreviated}/{month.abbreviated}/{year.full}")]
Copy link
Contributor

Choose a reason for hiding this comment

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

The test previously passed with
[InlineData("ddd/MMM/yyyy", "{day.integer} {dayofweek.abbreviated}/{month.abbreviated}/{year.full}")]
?

Should we validate the resulting string as well or include a different test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test validates that the input string gets translated to the expected output, which should be what I changed it to here (hence why I did). So to validate the existing string, it would be a new test to validate that the previous string that was there ({day.integer} {dayofweek.abbreviated}) is incorrect, so we don't regress it when making changes.

I'm not sure how important that is, but I'm not against doing it.

[InlineData("dddd/MMMM/yyyy", "{dayofweek.full}/{month.full}/{year.full}")]
public async Task FormatInitializesCorrectly(string format, string nativeFormat)
{
Expand Down
Loading