diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2018-01-30 14:42:33 -0800 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2018-01-30 14:42:33 -0800 |
| commit | 2bc105cd95a457caf44623a742ddf4040bee4d20 (patch) | |
| tree | cdf6ae474637400dc5f796f775ec3cae2f4aa777 /scripts | |
| parent | 6741689094628b94326c5c410b546f393e57a0e4 (diff) | |
| download | vcpkg-2bc105cd95a457caf44623a742ddf4040bee4d20.tar.gz vcpkg-2bc105cd95a457caf44623a742ddf4040bee4d20.zip | |
Add vcpkgFormatElapsedTime in powershell side
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/VcpkgPowershellUtils.ps1 | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/scripts/VcpkgPowershellUtils.ps1 b/scripts/VcpkgPowershellUtils.ps1 index 63da1a508..722d337ca 100644 --- a/scripts/VcpkgPowershellUtils.ps1 +++ b/scripts/VcpkgPowershellUtils.ps1 @@ -195,4 +195,29 @@ function vcpkgInvokeCommandClean() $ec = $process.ExitCode Write-Verbose "Execution terminated with exit code $ec." return $ec +} + +function vcpkgFormatElapsedTime([TimeSpan]$ts) +{ + if ($ts.TotalHours -ge 1) + { + return [string]::Format( "{0:N2} h", $ts.TotalHours); + } + + if ($ts.TotalMinutes -ge 1) + { + return [string]::Format( "{0:N2} min", $ts.TotalMinutes); + } + + if ($ts.TotalSeconds -ge 1) + { + return [string]::Format( "{0:N2} s", $ts.TotalSeconds); + } + + if ($ts.TotalMilliseconds -ge 1) + { + return [string]::Format( "{0:N2} ms", $ts.TotalMilliseconds); + } + + throw $ts }
\ No newline at end of file |
