From 121369d9c082a2756d845774ab557c623bf404a7 Mon Sep 17 00:00:00 2001 From: Elouan Martinet Date: Sun, 15 Nov 2020 18:26:35 +0100 Subject: [PATCH] Add basic duration comparison --- core/condition.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/condition.go b/core/condition.go index 964416fd..cf13e87b 100644 --- a/core/condition.go +++ b/core/condition.go @@ -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 {