Add basic duration comparison

This commit is contained in:
Elouan Martinet 2020-11-15 18:26:35 +01:00
parent d1f24dbea4
commit 121369d9c0

View File

@ -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 {