[new] count words & stats, [new] refactor metadata, [new] human readable time

This commit is contained in:
2023-10-01 19:17:22 -04:00
parent 5a8bdacf4f
commit 2a101c6cee
13 changed files with 816 additions and 239 deletions

View File

@@ -1,5 +1,10 @@
package utils
import (
"fmt"
"math"
)
type UTCOffset struct {
Name string
Value string
@@ -49,3 +54,27 @@ var UTC_OFFSETS = []UTCOffset{
func GetUTCOffsets() []UTCOffset {
return UTC_OFFSETS
}
func NiceSeconds(input int64) (result string) {
days := math.Floor(float64(input) / 60 / 60 / 24)
seconds := input % (60 * 60 * 24)
hours := math.Floor(float64(seconds) / 60 / 60)
seconds = input % (60 * 60)
minutes := math.Floor(float64(seconds) / 60)
seconds = input % 60
if days > 0 {
result += fmt.Sprintf("%dd ", int(days))
}
if hours > 0 {
result += fmt.Sprintf("%dh ", int(hours))
}
if minutes > 0 {
result += fmt.Sprintf("%dm ", int(minutes))
}
if seconds > 0 {
result += fmt.Sprintf("%ds", int(seconds))
}
return
}