From 468e0c393c7111e44b77de92f9762544fa2924c3 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Thu, 7 Sep 2017 17:57:15 +0300 Subject: [PATCH] Correct %c format in Get-Date -UFormat Add leading zero in day --- .../commands/utility/GetDateCommand.cs | 4 +--- .../Modules/Microsoft.PowerShell.Utility/Get-Date.Tests.ps1 | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetDateCommand.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetDateCommand.cs index 5533721b5f6..c29e4de5a28 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetDateCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetDateCommand.cs @@ -369,9 +369,7 @@ private string UFormatDateString(DateTime dateTime) break; case 'c': - sb.Append("{0:ddd} {0:MMM} "); - sb.Append(StringUtil.Format("{0,2} ", dateTime.Day)); - sb.Append("{0:HH}:{0:mm}:{0:ss} {0:yyyy}"); + sb.Append("{0:ddd} {0:MMM} {0:dd} {0:HH}:{0:mm}:{0:ss} {0:yyyy}"); break; case 'D': diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-Date.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-Date.Tests.ps1 index fade58e6ece..011dd32cbb1 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-Date.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-Date.Tests.ps1 @@ -30,7 +30,7 @@ Describe "Get-Date DRT Unit Tests" -Tags "CI" { } It "using -uformat 'aAbBcCdDehHIjmMpr' produces the correct output" { - Get-date -Date 1/1/0030 -uformat %a%A%b%B%c%C%d%D%e%h%H%I%j%m%M%p%r | Should be "TueTuesdayJanJanuaryTue Jan 1 00:00:00 003000101/01/30 1Jan001210100AM12:00:00 AM" + Get-date -Date 1/1/0030 -uformat %a%A%b%B%c%C%d%D%e%h%H%I%j%m%M%p%r | Should be "TueTuesdayJanJanuaryTue Jan 01 00:00:00 003000101/01/30 1Jan001210100AM12:00:00 AM" } It "using -uformat 'StTuUVwWxXyYZ' produces the correct output" {