1
0
Fork 0
mirror of https://github.com/TwiN/gatus.git synced 2024-12-14 11:58:04 +00:00

Revert "Add day format support for duration comparison"

This reverts commit 21509428
This commit is contained in:
TwinProduction 2020-11-17 12:16:40 -05:00
parent 2150942876
commit e79c849e6d

View file

@ -3,7 +3,6 @@ package core
import (
"fmt"
"log"
"regexp"
"strconv"
"strings"
"time"
@ -187,15 +186,7 @@ func sanitizeAndResolve(list []string, result *Result) []string {
func sanitizeAndResolveNumerical(list []string, result *Result) []int64 {
var sanitizedNumbers []int64
sanitizedList := sanitizeAndResolve(list, result)
dayRegex := regexp.MustCompile(`^\s*(\d+)d\s*$`)
for _, element := range sanitizedList {
if matches := dayRegex.FindStringSubmatch(element); matches != nil {
if days, err := strconv.ParseInt(matches[1], 10, 64); err == nil {
duration := time.Duration(days * int64(time.Hour * 24))
sanitizedNumbers = append(sanitizedNumbers, duration.Milliseconds())
continue
}
}
if duration, err := time.ParseDuration(element); duration != 0 && err == nil {
sanitizedNumbers = append(sanitizedNumbers, duration.Milliseconds())
} else if number, err := strconv.ParseInt(element, 10, 64); err != nil {