From 0e9220e57e0d22ab7e9e3972c40013317e0ff750 Mon Sep 17 00:00:00 2001 From: Dominik Titl <78549750+morning4coffe-dev@users.noreply.github.com> Date: Tue, 17 Dec 2024 20:46:46 +0100 Subject: [PATCH] chore: Add runtime test for Time format --- .../Given_DateTimeFormatter.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_Globalization/Given_DateTimeFormatter.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_Globalization/Given_DateTimeFormatter.cs index 557870ff2c19..54ebd37a74cc 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_Globalization/Given_DateTimeFormatter.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_Globalization/Given_DateTimeFormatter.cs @@ -104,19 +104,18 @@ public void When_FormattingDateVariants_ShouldProduceExpectedFormats() } } - // TODO(DT): Currently is throwing unexpected results on WinUI as well, can't compare the expected results - /* [TestMethod] + [TestMethod] public void When_FormattingTimeVariants_ShouldProduceExpectedFormats() { var expectedResults = new Dictionary { { "{hour.integer}:{minute.integer}", "14:30" }, - { "{hour.integer}:{minute.integer}:{second.integer}", "14:30:00" }, + { "{hour.integer}:{minute.integer}:{second.integer(2)}", "14:30:00" }, { "{hour.integer}:{minute.integer} {period.abbreviated(2)}", "2:30 PM" }, - { "{hour.integer}:{minute.integer}:{second.integer} {period.abbreviated(2)}", "2:30:00 PM" }, - { "{minute.integer}:{second.integer}", "30:00" }, + { "{hour.integer}:{minute.integer}:{second.integer} {period.abbreviated(2)}", "2:30:0 PM" }, + { "{minute.integer}:{second.integer}", "30:0" }, { "{second.integer}", "0" }, - { "{hour.integer}:{minute.integer}:{second.integer} UTC", "14:30:00 UTC" } + { "{hour.integer}:{minute.integer}:{second.integer(2)} UTC", "14:30:00 UTC" } }; foreach (var kvp in expectedResults) @@ -124,11 +123,12 @@ public void When_FormattingTimeVariants_ShouldProduceExpectedFormats() var template = kvp.Key; var expected = kvp.Value; - var formatter = new DateTimeFormatter(template); - var formattedTime = formatter.Format(_testDate); + var clock = template.Contains("period") ? ClockIdentifiers.TwelveHour : ClockIdentifiers.TwentyFourHour; + + var formatter = new DateTimeFormatter(template, ["en-US"], "US", CalendarIdentifiers.Gregorian, clock); + var formattedTime = formatter.Format(new DateTime(2024, 6, 17, 14, 30, 0)); Assert.AreEqual(expected, formattedTime, $"Mismatch for template: {template}"); - Console.WriteLine($"Template: {template}, Result: {formattedTime}"); } - }*/ + } }