From e30229a0a572d2f429d5630b30a57a2d4cc2636b Mon Sep 17 00:00:00 2001 From: Lee Miller Date: Thu, 15 Jun 2023 12:59:41 -0700 Subject: [PATCH] Fix day format in TimeSkill (#1466) The TimeSkill class was using the wrong format specifier for the day of the month, resulting in a two-digit year instead. This commit changes the format from "DD" to "dd", which correctly outputs the day as a number from 01 to 31. This fixes a potential confusion and inconsistency in the output of the TimeSkill methods. Co-authored-by: Lee Miller --- .../CoreSkills/TimeSkillTests.cs | 10 ++++++++++ dotnet/src/SemanticKernel/CoreSkills/TimeSkill.cs | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/dotnet/src/SemanticKernel.UnitTests/CoreSkills/TimeSkillTests.cs b/dotnet/src/SemanticKernel.UnitTests/CoreSkills/TimeSkillTests.cs index 532133ed6993..d2db9b3266d7 100644 --- a/dotnet/src/SemanticKernel.UnitTests/CoreSkills/TimeSkillTests.cs +++ b/dotnet/src/SemanticKernel.UnitTests/CoreSkills/TimeSkillTests.cs @@ -42,6 +42,16 @@ public void DaysAgo() Assert.Equal(expected.Year, returned.Year); } + [Fact] + public void Day() + { + string expected = DateTime.Now.ToString("dd", CultureInfo.CurrentCulture); + var skill = new TimeSkill(); + string result = skill.Day(); + Assert.Equal(expected, result); + Assert.True(int.TryParse(result, out _)); + } + [Fact] public void LastMatchingDayBadInput() { diff --git a/dotnet/src/SemanticKernel/CoreSkills/TimeSkill.cs b/dotnet/src/SemanticKernel/CoreSkills/TimeSkill.cs index 28888e3d8d8f..c89683dbeb5e 100644 --- a/dotnet/src/SemanticKernel/CoreSkills/TimeSkill.cs +++ b/dotnet/src/SemanticKernel/CoreSkills/TimeSkill.cs @@ -159,7 +159,7 @@ public string MonthNumber() public string Day() { // Example: 12 - return DateTimeOffset.Now.ToString("DD", CultureInfo.CurrentCulture); + return DateTimeOffset.Now.ToString("dd", CultureInfo.CurrentCulture); } ///