mirror of
https://github.com/TwiN/gatus.git
synced 2025-01-24 14:58:41 +01:00
Add basic duration comparison
This commit is contained in:
parent
d1f24dbea4
commit
121369d9c0
@ -7,6 +7,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -185,7 +186,9 @@ func sanitizeAndResolveNumerical(list []string, result *Result) []int64 {
|
|||||||
var sanitizedNumbers []int64
|
var sanitizedNumbers []int64
|
||||||
sanitizedList := sanitizeAndResolve(list, result)
|
sanitizedList := sanitizeAndResolve(list, result)
|
||||||
for _, element := range sanitizedList {
|
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
|
// Default to 0 if the string couldn't be converted to an integer
|
||||||
sanitizedNumbers = append(sanitizedNumbers, 0)
|
sanitizedNumbers = append(sanitizedNumbers, 0)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user