Stricter floats.

This commit is contained in:
Nuno Cruces
2025-12-12 17:21:33 +00:00
parent 5b78823416
commit 8dca850bee
8 changed files with 109 additions and 24 deletions

View File

@@ -1,6 +1,7 @@
package sql3util
import (
"strconv"
"strings"
"time"
)
@@ -67,6 +68,15 @@ func ParseBool(s string) (b, ok bool) {
return false, false
}
// ParseFloat parses a decimal floating point number.
func ParseFloat(s string) (f float64, ok bool) {
if strings.TrimLeft(s, "+-.0123456789Ee") != "" {
return
}
f, err := strconv.ParseFloat(s, 64)
return f, err == nil
}
// ParseTimeShift parses a time shift modifier,
// also the output of timediff.
//