mirror of
https://github.com/TwiN/gatus.git
synced 2025-01-09 07:28:29 +01:00
Add basic duration comparison
This commit is contained in:
parent
d1f24dbea4
commit
121369d9c0
@ -7,6 +7,7 @@ import (
|
||||
"log"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -185,7 +186,9 @@ func sanitizeAndResolveNumerical(list []string, result *Result) []int64 {
|
||||
var sanitizedNumbers []int64
|
||||
sanitizedList := sanitizeAndResolve(list, result)
|
||||
for _, element := range sanitizedList {
|
||||
if number, err := strconv.ParseInt(element, 10, 64); err != nil {
|
||||
if duration, err := time.ParseDuration(element); err == nil {
|
||||
sanitizedNumbers = append(sanitizedNumbers, duration.Milliseconds())
|
||||
} else if number, err := strconv.ParseInt(element, 10, 64); err != nil {
|
||||
// Default to 0 if the string couldn't be converted to an integer
|
||||
sanitizedNumbers = append(sanitizedNumbers, 0)
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user