Extend pkg/expr functions
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"github.com/PaesslerAG/gval"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/PaesslerAG/gval"
|
||||
)
|
||||
|
||||
func StringFunctions() []gval.Language {
|
||||
@@ -15,6 +17,7 @@ func StringFunctions() []gval.Language {
|
||||
gval.Function("toUpper", strings.ToUpper),
|
||||
gval.Function("shortest", shortest),
|
||||
gval.Function("longest", longest),
|
||||
gval.Function("format", fmt.Sprintf),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/PaesslerAG/gval"
|
||||
"github.com/lestrrat-go/strftime"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TimeFunctions() []gval.Language {
|
||||
@@ -64,6 +65,6 @@ func modTime(t time.Time, mod interface{}) (time.Time, error) {
|
||||
// More details here:
|
||||
// https://github.com/lestrrat-go/strftime#supported-conversion-specifications
|
||||
func strfTime(t time.Time, f string) string {
|
||||
o, _ := strftime.Format(f, t)
|
||||
o, _ := strftime.Format(f, t, strftime.WithMilliseconds('b'))
|
||||
return o
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user