PowerShell_Scripts/base/ConvertFrom-TimeSpan.ps1

16 lines
424 B
PowerShell

param([TimeSpan]$TimeSpan, [switch]$NoSeconds)
$local:out = [string]::Empty
if( $TimeSpan.Days ) {
$out = "$($TimeSpan.Days)d "
}
if( $out -or $TimeSpan.Hours ) {
$out += "$($TimeSpan.Hours)h "
}
if( $out -or $TimeSpan.Minutes -or ($NoSeconds -and -not $out) ) {
$out += "$($TimeSpan.Minutes)m "
}
if( -not $NoSeconds -and ($TimeSpan.Seconds -or -not $out) ) {
$out += "$($TimeSpan.Seconds)s"
}
$out.Trim();