(s string)
| 128 | } |
| 129 | |
| 130 | func GetTimeFromText(s string) (int, int) { |
| 131 | s = strings.ReplaceAll(s, " - ", "") |
| 132 | s = strings.ReplaceAll(s, " @", " ") |
| 133 | s = strings.ReplaceAll(s, "?", " ") |
| 134 | words := strings.Split(s, " ") |
| 135 | Time := 0 |
| 136 | TimeTo := 0 |
| 137 | maxScore := 0 |
| 138 | for _, w := range words { |
| 139 | score := 0 |
| 140 | w2 := "" |
| 141 | if strings.Contains(w, "-") { |
| 142 | w2 = strings.Split(w, "-")[1] |
| 143 | w = strings.Split(w, "-")[0] |
| 144 | score += 1 |
| 145 | } |
| 146 | w = strings.TrimSuffix(w, "s") |
| 147 | w2 = strings.TrimSuffix(w2, "s") |
| 148 | if strings.Contains(w, ":") { |
| 149 | score += 2 |
| 150 | } |
| 151 | if score > maxScore { |
| 152 | t, err := TimeStringToSeconds(w) |
| 153 | if err == nil { |
| 154 | Time = t |
| 155 | TimeTo, _ = TimeStringToSeconds(w2) // if w2 is empty or not a correct time, TimeTo is 0 |
| 156 | maxScore = score |
| 157 | } |
| 158 | } |
| 159 | } |
| 160 | return Time, TimeTo |
| 161 | } |
| 162 | |
| 163 | func linksFromBody(body string) [][]string { |
| 164 | results := markdownRegex.FindAllStringSubmatch(body, -1) |
no test coverage detected