sneak
0d9ed8874f
All checks were successful
continuous-integration/drone/push Build is passing
* `make` works again, exporting correct database file path for local dev * better formatting of durations * refactored duration math to misc functions * now tracks and displays score * displays short-lifetime fp wipeouts in red
21 lines
428 B
Go
21 lines
428 B
Go
package hn
|
|
|
|
import (
|
|
"math"
|
|
"time"
|
|
|
|
"github.com/hako/durafmt"
|
|
)
|
|
|
|
func timeDiffHuman(first time.Time, second time.Time) string {
|
|
if first.Before(second) {
|
|
return durafmt.ParseShort(second.Sub(first)).String()
|
|
} else {
|
|
return durafmt.ParseShort(first.Sub(second)).String()
|
|
}
|
|
}
|
|
|
|
func timeDiffAbsSeconds(first time.Time, second time.Time) uint {
|
|
return uint(math.Abs(first.Sub(second).Truncate(time.Second).Seconds()))
|
|
}
|