MCPcopy Create free account
hub / github.com/AudDMusic/RedditBot / TimeStringToSeconds

Function TimeStringToSeconds

main.go:106–121  ·  view source on GitHub ↗
(s string)

Source from the content-addressed store, hash-verified

104}
105
106func TimeStringToSeconds(s string) (int, error) {
107 list := strings.Split(s, ":")
108 if len(list) > 3 {
109 return 0, fmt.Errorf("too many : thingies")
110 }
111 result, multiplier := 0, 1
112 for i := len(list) - 1; i >= 0; i-- {
113 c, err := strconv.Atoi(list[i])
114 if err != nil {
115 return 0, err
116 }
117 result += c * multiplier
118 multiplier *= 60
119 }
120 return result, nil
121}
122
123func SecondsToTimeString(i int, includeHours bool) string {
124 if includeHours {

Callers 1

GetTimeFromTextFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected