29 lines
490 B
Go
29 lines
490 B
Go
package utils
|
|
|
|
import (
|
|
"github.com/hako/durafmt"
|
|
"time"
|
|
)
|
|
|
|
// Now returns the UTC timestamp
|
|
func Now() time.Time {
|
|
return time.Now().UTC()
|
|
}
|
|
|
|
type Duration struct {
|
|
time.Duration
|
|
}
|
|
|
|
func (d Duration) Human() string {
|
|
return durafmt.Parse(d.Duration).LimitFirstN(2).String()
|
|
}
|
|
|
|
// FormatDuration converts a time.Duration into a string
|
|
func FormatDuration(d time.Duration) string {
|
|
return durafmt.ParseShort(d).LimitFirstN(3).String()
|
|
}
|
|
|
|
func rev(f float64) float64 {
|
|
return f * -1
|
|
}
|