Spaces:
Sleeping
Sleeping
Download test-clone/internal/utils/time_format.go from codebydante/BrodyFileStreamBot: direct link, hf CLI and curl.
- Browser
- Download file 907 Bytes
-
https://huggingface.co/spaces/codebydante/BrodyFileStreamBot/resolve/bd894b382ed6a42e3879e3846027d7e6d427f3f2/test-clone/internal/utils/time_format.go
- Command line
-
hf download hf://spaces/codebydante/BrodyFileStreamBot@bd894b382ed6a42e3879e3846027d7e6d427f3f2/test-clone/internal/utils/time_format.go
-
curl -L -o time_format.go https://huggingface.co/spaces/codebydante/BrodyFileStreamBot/resolve/bd894b382ed6a42e3879e3846027d7e6d427f3f2/test-clone/internal/utils/time_format.go
907 Bytes
| package utils | |
| import ( | |
| "fmt" | |
| "math/bits" | |
| ) | |
| func TimeFormat(seconds uint64) (timeStr string) { | |
| hours, remainder := bits.Div64(0, seconds, 3600) | |
| minutes, seconds := bits.Div64(0, remainder, 60) | |
| days, hours := bits.Div64(0, hours, 24) | |
| timeStr = "" | |
| if days > 0 { | |
| if days == 1 { | |
| timeStr += fmt.Sprintf("%d day, ", days) | |
| } else { | |
| timeStr += fmt.Sprintf("%d days, ", days) | |
| } | |
| } | |
| if hours > 0 { | |
| if hours == 1 { | |
| timeStr += fmt.Sprintf("%d hour, ", hours) | |
| } else { | |
| timeStr += fmt.Sprintf("%d hours, ", hours) | |
| } | |
| } | |
| if minutes > 0 { | |
| if minutes == 1 { | |
| timeStr += fmt.Sprintf("%d minute, ", minutes) | |
| } else { | |
| timeStr += fmt.Sprintf("%d minutes, ", minutes) | |
| } | |
| } | |
| if seconds > 0 { | |
| if seconds == 1 { | |
| timeStr += fmt.Sprintf("%d second", seconds) | |
| } else { | |
| timeStr += fmt.Sprintf("%d seconds", seconds) | |
| } | |
| } | |
| return timeStr | |
| } | |