aboutsummaryrefslogtreecommitdiff
path: root/pkg/util/util.go
blob: c0b5a174953b9d9340c5e7adcf94d9d2d33e71b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package util

import "time"

// TimeFormat formats the given time, where an empty time is formatted as "not set".
func TimeFormat(t time.Time) string {
	if t.IsZero() {
		return "not set"
	}

	return t.Format(time.ANSIC)
}

// Days returns the number of days in a duration. Fraction of days are discarded.
func Days(d time.Duration) int {
	return int(d.Hours() / 24)
}