diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 697c747913..5c579d9d24 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,6 @@ +#### 0.11.14 - 03.11.2014 +* BUGFIX: Paket timing was incorrect - https://github.com/fsprojects/Paket/issues/326 + #### 0.11.13 - 02.11.2014 * Trace warning when we replace NuGet.exe with NuGet.CommandLine - https://github.com/fsprojects/Paket/issues/320 diff --git a/src/Paket.Core/Utils.fs b/src/Paket.Core/Utils.fs index dc7b5ab00d..c1e4980ea9 100644 --- a/src/Paket.Core/Utils.fs +++ b/src/Paket.Core/Utils.fs @@ -20,6 +20,21 @@ type Auth = { Username : AuthEntry Password : AuthEntry } + +let TimeSpanToReadableString(span:TimeSpan) = + let pluralize x = if x = 1 then String.Empty else "s" + let notZero x y = if x > 0 then y else String.Empty + let days = notZero (span.Duration().Days) <| String.Format("{0:0} day{1}, ", span.Days, pluralize span.Days) + let hours = notZero (span.Duration().Hours) <| String.Format("{0:0} hour{1}, ", span.Hours, pluralize span.Hours) + let minutes = notZero (span.Duration().Minutes) <| String.Format("{0:0} minute{1}, ", span.Minutes, pluralize span.Minutes) + let seconds = notZero (span.Duration().Seconds) <| String.Format("{0:0} second{1}", span.Seconds, pluralize span.Seconds) + + let formatted = String.Format("{0}{1}{2}{3}", days, hours, minutes, seconds) + + let formatted = if formatted.EndsWith(", ") then formatted.Substring(0, formatted.Length - 2) else formatted + + if String.IsNullOrEmpty(formatted) then "0 seconds" else formatted + /// Creates a directory if it does not exist. let CreateDir path = let dir = DirectoryInfo path diff --git a/src/Paket/Program.fs b/src/Paket/Program.fs index 38378be74e..38365c99fc 100644 --- a/src/Paket/Program.fs +++ b/src/Paket/Program.fs @@ -136,8 +136,7 @@ try | Command.Simplify -> Simplifier.Simplify(interactive) | _ -> traceErrorfn "no command given.%s" (parser.Usage()) - let ts = stopWatch.Elapsed - let elapsedTime = String.Format("{0:00}.{1:00}s", ts.Seconds, ts.Milliseconds / 10) + let elapsedTime = Utils.TimeSpanToReadableString stopWatch.Elapsed tracefn "%s - ready." elapsedTime | None -> ()