From 2bc105cd95a457caf44623a742ddf4040bee4d20 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Tue, 30 Jan 2018 14:42:33 -0800 Subject: Add vcpkgFormatElapsedTime in powershell side --- scripts/VcpkgPowershellUtils.ps1 | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'scripts') 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 -- cgit v1.2.3