Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ public int Millisecond
/// Unix format string
/// </summary>
[Parameter(ParameterSetName = "UFormat")]
[ValidateNotNullOrEmpty]
public string UFormat { get; set; }


Expand Down Expand Up @@ -332,7 +333,6 @@ private string UFormatDateString(DateTime dateTime)
int offset = 0;
StringBuilder sb = new StringBuilder();


// folks may include the "+" as part of the format string
if (UFormat[0] == '+')
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ Describe "Get-Date DRT Unit Tests" -Tags "CI" {
Get-date -Date 1/1/0030 -uformat %S%T%u%U%V%w%W%x%X%y%Y%% | Should be "0000:00:002012001/01/3000:00:00300030%"
}

It "Passing '<name>' to -uformat produces a descriptive error" -TestCases @(
@{ name = "`$null" ; value = $null }
@{ name = "empty string"; value = "" }
) {
param($value)
{ Get-date -Date 1/1/1970 -uformat $value -ErrorAction Stop } | ShouldBeErrorId "ParameterArgumentValidationError,Microsoft.PowerShell.Commands.GetDateCommand"
}

It "Get-date works with pipeline input" {
$x = new-object System.Management.Automation.PSObject
$x | add-member NoteProperty Date ([DateTime]::Now)
Expand Down