Skip to content

Commit

Permalink
BUGFIX: Paket timing was incorrect -closes #326
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Nov 3, 2014
1 parent b8cd032 commit cad9bbd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
15 changes: 15 additions & 0 deletions src/Paket.Core/Utils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/Paket/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 -> ()
Expand Down

0 comments on commit cad9bbd

Please sign in to comment.