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:
@ -2,25 +2,27 @@ package datetime
|
|||||||
|
|
||||||
import "github.com/MontFerret/ferret/pkg/runtime/core"
|
import "github.com/MontFerret/ferret/pkg/runtime/core"
|
||||||
|
|
||||||
func NewLib() map[string]core.Function {
|
func RegisterLib(ns core.Namespace) error {
|
||||||
return map[string]core.Function{
|
return ns.RegisterFunctions(
|
||||||
"NOW": Now,
|
core.NewFunctionsFromMap(map[string]core.Function{
|
||||||
"DATE": Date,
|
"NOW": Now,
|
||||||
"DATE_DAYOFWEEK": DateDayOfWeek,
|
"DATE": Date,
|
||||||
"DATE_YEAR": DateYear,
|
"DATE_DAYOFWEEK": DateDayOfWeek,
|
||||||
"DATE_MONTH": DateMonth,
|
"DATE_YEAR": DateYear,
|
||||||
"DATE_DAY": DateDay,
|
"DATE_MONTH": DateMonth,
|
||||||
"DATE_HOUR": DateHour,
|
"DATE_DAY": DateDay,
|
||||||
"DATE_MINUTE": DateMinute,
|
"DATE_HOUR": DateHour,
|
||||||
"DATE_SECOND": DateSecond,
|
"DATE_MINUTE": DateMinute,
|
||||||
"DATE_MILLISECOND": DateMillisecond,
|
"DATE_SECOND": DateSecond,
|
||||||
"DATE_DAYOFYEAR": DateDayOfYear,
|
"DATE_MILLISECOND": DateMillisecond,
|
||||||
"DATE_LEAPYEAR": DateLeapYear,
|
"DATE_DAYOFYEAR": DateDayOfYear,
|
||||||
"DATE_QUARTER": DateQuarter,
|
"DATE_LEAPYEAR": DateLeapYear,
|
||||||
"DATE_DAYS_IN_MONTH": DateDaysInMonth,
|
"DATE_QUARTER": DateQuarter,
|
||||||
"DATE_FORMAT": DateFormat,
|
"DATE_DAYS_IN_MONTH": DateDaysInMonth,
|
||||||
"DATE_ADD": DateAdd,
|
"DATE_FORMAT": DateFormat,
|
||||||
"DATE_SUBTRACT": DateSubtract,
|
"DATE_ADD": DateAdd,
|
||||||
"DATE_DIFF": DateDiff,
|
"DATE_SUBTRACT": DateSubtract,
|
||||||
}
|
"DATE_DIFF": DateDiff,
|
||||||
|
}),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"github.com/MontFerret/ferret/pkg/runtime/core"
|
"github.com/MontFerret/ferret/pkg/runtime/core"
|
||||||
"github.com/MontFerret/ferret/pkg/stdlib/arrays"
|
"github.com/MontFerret/ferret/pkg/stdlib/arrays"
|
||||||
"github.com/MontFerret/ferret/pkg/stdlib/collections"
|
"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/html"
|
||||||
"github.com/MontFerret/ferret/pkg/stdlib/io"
|
"github.com/MontFerret/ferret/pkg/stdlib/io"
|
||||||
"github.com/MontFerret/ferret/pkg/stdlib/math"
|
"github.com/MontFerret/ferret/pkg/stdlib/math"
|
||||||
@ -30,6 +31,10 @@ func RegisterLib(ns core.Namespace) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := datetime.RegisterLib(ns); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if err := arrays.RegisterLib(ns); err != nil {
|
if err := arrays.RegisterLib(ns); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user