2022-10-10 16:34:07 +02:00
|
|
|
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 ""
|
|
|
|
}
|
|
|
|
|
2023-02-22 16:33:33 +01:00
|
|
|
return t.UTC().Format("2006-01-02 15:04:05")
|
2022-10-10 16:34:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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)
|
|
|
|
}
|
|
|
|
}
|