aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2018-01-30 14:42:33 -0800
committerAlexander Karatarakis <alkarata@microsoft.com>2018-01-30 14:42:33 -0800
commit2bc105cd95a457caf44623a742ddf4040bee4d20 (patch)
treecdf6ae474637400dc5f796f775ec3cae2f4aa777 /scripts
parent6741689094628b94326c5c410b546f393e57a0e4 (diff)
downloadvcpkg-2bc105cd95a457caf44623a742ddf4040bee4d20.tar.gz
vcpkg-2bc105cd95a457caf44623a742ddf4040bee4d20.zip
Add vcpkgFormatElapsedTime in powershell side
Diffstat (limited to 'scripts')
-rw-r--r--scripts/VcpkgPowershellUtils.ps125
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