Skip to content

Commit

Permalink
Fix day format in TimeSkill (#1466)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
lemillermicrosoft and lemillermicrosoft authored Jun 15, 2023
1 parent fa8b8b7 commit e30229a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions dotnet/src/SemanticKernel.UnitTests/CoreSkills/TimeSkillTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
2 changes: 1 addition & 1 deletion dotnet/src/SemanticKernel/CoreSkills/TimeSkill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/// <summary>
Expand Down

0 comments on commit e30229a

Please sign in to comment.