photoprism/pkg/txt/time.go
Michael Mayer eaff0abb6d Videos: Index and display durations of less than one second #3224
Signed-off-by: Michael Mayer <michael@photoprism.app>
2023-02-22 16:33:33 +01:00

26 lines
467 B
Go

package txt
import (
"fmt"
"time"
)
// TimeStamp converts a time to a timestamp string for reporting.
func TimeStamp(t *time.Time) string {
if t == nil {
return ""
} else if t.IsZero() {
return ""
}
return t.UTC().Format("2006-01-02 15:04:05")
}
// NTimes converts an integer to a string in the format "n times" or returns an empty string if n is 0.
func NTimes(n int) string {
if n < 2 {
return ""
} else {
return fmt.Sprintf("%d times", n)
}
}