1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-07-05 00:49:00 +02:00

Added missed datetime library (#462)

This commit is contained in:
Tim Voronov
2020-03-10 21:18:04 -04:00
committed by GitHub
parent b08a23293a
commit e4464d9de9
2 changed files with 28 additions and 21 deletions

View File

@ -2,8 +2,9 @@ package datetime
import "github.com/MontFerret/ferret/pkg/runtime/core"
func NewLib() map[string]core.Function {
return map[string]core.Function{
func RegisterLib(ns core.Namespace) error {
return ns.RegisterFunctions(
core.NewFunctionsFromMap(map[string]core.Function{
"NOW": Now,
"DATE": Date,
"DATE_DAYOFWEEK": DateDayOfWeek,
@ -22,5 +23,6 @@ func NewLib() map[string]core.Function {
"DATE_ADD": DateAdd,
"DATE_SUBTRACT": DateSubtract,
"DATE_DIFF": DateDiff,
}
}),
)
}

View File

@ -4,6 +4,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/stdlib/arrays"
"github.com/MontFerret/ferret/pkg/stdlib/collections"
"github.com/MontFerret/ferret/pkg/stdlib/datetime"
"github.com/MontFerret/ferret/pkg/stdlib/html"
"github.com/MontFerret/ferret/pkg/stdlib/io"
"github.com/MontFerret/ferret/pkg/stdlib/math"
@ -30,6 +31,10 @@ func RegisterLib(ns core.Namespace) error {
return err
}
if err := datetime.RegisterLib(ns); err != nil {
return err
}
if err := arrays.RegisterLib(ns); err != nil {
return err
}