MCPcopy Create free account
hub / github.com/ForestHubAI/edge-agents / parseHHMM

Function parseHHMM

go/engine/node/trigger/alarm.go:98–115  ·  view source on GitHub ↗
(s string)

Source from the content-addressed store, hash-verified

96}
97
98func parseHHMM(s string) (int, int, error) {
99 parts := strings.SplitN(s, ":", 2)
100 if len(parts) != 2 {
101 return 0, 0, fmt.Errorf("invalid time %q: expected HH:MM", s)
102 }
103 h, err := strconv.Atoi(parts[0])
104 if err != nil {
105 return 0, 0, fmt.Errorf("invalid hour in %q: %w", s, err)
106 }
107 m, err := strconv.Atoi(parts[1])
108 if err != nil {
109 return 0, 0, fmt.Errorf("invalid minute in %q: %w", s, err)
110 }
111 if h < 0 || h > 23 || m < 0 || m > 59 {
112 return 0, 0, fmt.Errorf("time %q out of range (00:00-23:59)", s)
113 }
114 return h, m, nil
115}
116
117func parseDays(days []string) ([]time.Weekday, error) {
118 if len(days) == 0 {

Callers 2

TestParseHHMMFunction · 0.85
NewAlarmFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestParseHHMMFunction · 0.68