diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetDateCommand.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetDateCommand.cs index eec55461aa..a10bc14c36 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetDateCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetDateCommand.cs @@ -372,6 +372,10 @@ namespace Microsoft.PowerShell.Commands sb.Append(StringUtil.Format("{0,2}", dateTime.Day)); break; + case 'F': + sb.Append("{0:yyyy}-{0:MM}-{0:dd}"); + break; + case 'G': sb.Append("{0:yyyy}"); break; 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 9b53b0572d..1d66eb66ed 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-Date.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-Date.Tests.ps1 @@ -208,7 +208,7 @@ Describe "Get-Date -UFormat tests" -Tags "CI" { @{ date = $date1; format = "%D"; result = "04/05/30" } # date; same as %m/%d/%y @{ date = $date1; format = "%e"; result = " 5" } # day of month, space padded; same as %_d @{ date = $date2; format = "%e"; result = "15" } - #@{ date = $date1; format = "%F"; result = "" } + @{ date = $date1; format = "%F"; result = "2030-04-05" }# Equivalent to %Y-%m-%d (the ISO 8601 date format). #@{ date = $date1; format = "%g"; result = "" } # last two digits of year of ISO week number (see %G) # TODO: need review. Broken C# implementation. #