added share list page

This commit is contained in:
Pijus Kamandulis
2025-05-27 22:56:44 +03:00
parent 1cc12afa16
commit 6f18e75688
7 changed files with 246 additions and 28 deletions

39
helpers/helpers.go Normal file
View File

@@ -0,0 +1,39 @@
package helpers
import (
"fmt"
"strconv"
"strings"
"time"
)
func HumanDiff(diff float64) string {
units := []string{"", "K", "M", "G", "T"}
i := 0
for diff >= 1000 && i < len(units)-1 {
diff /= 1000
i++
}
return fmt.Sprintf("%.2f%s", diff, units[i])
}
func ParseCreateDate(createdate string) time.Time {
parts := strings.Split(createdate, ",")
if len(parts) == 2 {
sec, _ := strconv.ParseInt(parts[0], 10, 64)
nsec, _ := strconv.ParseInt(parts[1], 10, 64)
return time.Unix(sec, nsec)
}
return time.Time{}
}
func FormatCreateDate(createdate string) string {
parts := strings.Split(createdate, ",")
if len(parts) == 2 {
sec, _ := strconv.ParseInt(parts[0], 10, 64)
nsec, _ := strconv.ParseInt(parts[1], 10, 64)
t := time.Unix(sec, nsec)
return t.Format(time.DateTime)
}
return ""
}