make duration more readable

This commit is contained in:
Daylin Morgan 2025-01-13 10:15:46 -06:00
parent 00c93702ad
commit d49948eae3
Signed by: daylin
GPG key ID: 950D13E9719334AD

View file

@ -324,7 +324,13 @@ type
duration*: Duration duration*: Duration
successful*: bool successful*: bool
func formatDuration(d: Duration): string =
## convert duration to: X minutes and Y seconds
let seconds = d.inSeconds
if seconds > 60:
result.add $(seconds div 60) & " minutes"
result.add " and "
result.add $(seconds mod 60) & " seconds"
proc build(drv: OizysDerivation, rest: seq[string]): BuildResult = proc build(drv: OizysDerivation, rest: seq[string]): BuildResult =
let startTime = now() let startTime = now()
@ -337,7 +343,7 @@ proc build(drv: OizysDerivation, rest: seq[string]): BuildResult =
result.duration = now() - startTime result.duration = now() - startTime
# TODO: make splitDrv more ergonmic? # TODO: make splitDrv more ergonmic?
info "succesfully built: " & splitDrv(drv.name).name info "succesfully built: " & splitDrv(drv.name).name
info "-> duration: " & $result.duration info "-> duration: " & formatDuration(result.duration)
func outputsPaths(o: OizysDerivation): seq[string] = func outputsPaths(o: OizysDerivation): seq[string] =
for _, output in o.drv.outputs: for _, output in o.drv.outputs: