mirror of
https://github.com/MontFerret/ferret.git
synced 2025-01-18 03:22:02 +02:00
Added missed DATE_COMPARE and updated comments (#537)
This commit is contained in:
parent
213f9b1fd6
commit
42cf623471
@ -14,7 +14,7 @@ var (
|
||||
emptyString values.String
|
||||
)
|
||||
|
||||
// DateAdd add amount given in unit to date.
|
||||
// DATE_ADD add amount given in unit to date.
|
||||
// @params date (DateTime) - source date.
|
||||
// @params amount (Int) - amount of units
|
||||
// @params unit (String) - unit.
|
||||
@ -44,7 +44,7 @@ func DateAdd(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
return values.NewDateTime(tm), nil
|
||||
}
|
||||
|
||||
// DateSubtract subtract amount given in unit to date.
|
||||
// DATE_SUBTRACT subtract amount given in unit to date.
|
||||
// @params date (DateTime) - source date.
|
||||
// @params amount (Int) - amount of units
|
||||
// @params unit (String) - unit.
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// DateCompare check if two partial dates match.
|
||||
// DATE_COMPARE check if two partial dates match.
|
||||
// @params date1, date2 (DateTime) - comparable dates.
|
||||
// @params unitRangeStart (String) - unit to start from.
|
||||
// @params unitRangeEnd (String, Optional) - unit to end with.
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// Date convert RFC3339 date time string to DateTime object.
|
||||
// DATE convert RFC3339 date time string to DateTime object.
|
||||
// @params timeString (String) - string in RFC3339 format.
|
||||
// @return (DateTime) - new DateTime object derived from timeString.
|
||||
func Date(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// DateDay returns the day of date as a number.
|
||||
// DATE_DAY returns the day of date as a number.
|
||||
// @params date (DateTime) - source DateTime.
|
||||
// @return (Int) - a day number.
|
||||
func DateDay(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// DateDayOfWeek returns number of the weekday from the date. Sunday is the 0th day of week.
|
||||
// DATE_DAYOFWEEK returns number of the weekday from the date. Sunday is the 0th day of week.
|
||||
// @params date (DateTime) - source DateTime.
|
||||
// @return (Int) - return number of the weekday.
|
||||
func DateDayOfWeek(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// DateDayOfYear returns the day of year number of date.
|
||||
// DATE_DAYOFYEAR returns the day of year number of date.
|
||||
// The return value range from 1 to 365 (366 in a leap year).
|
||||
// @params date (DateTime) - source DateTime.
|
||||
// @return (Int) - a day of year number.
|
||||
|
@ -24,7 +24,7 @@ var daysCount = map[time.Month]int{
|
||||
time.December: 31,
|
||||
}
|
||||
|
||||
// DateDaysInMonth returns the number of days in the month of date.
|
||||
// DATE_DAYS_IN_MONTH returns the number of days in the month of date.
|
||||
// @params date (DateTime) - source DateTime.
|
||||
// @return (Int) - number of the days.
|
||||
func DateDaysInMonth(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// DateDiff returns the difference between two dates in given time unit.
|
||||
// DATE_DIFF returns the difference between two dates in given time unit.
|
||||
// @params date1 (DateTime) - first DateTime.
|
||||
// @params date2 (DateTime) - second DateTime.
|
||||
// @params unit (String) - time unit to return the difference in.
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// DateFormat format date according to the given format string.
|
||||
// DATE_FORMAT format date according to the given format string.
|
||||
// @params date (DateTime) - source DateTime object.
|
||||
// @return (String) - formatted date.
|
||||
func DateFormat(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// DateHour returns the hour of date as a number.
|
||||
// DATE_HOUR returns the hour of date as a number.
|
||||
// @params date (DateTime) - source DateTime.
|
||||
// @return (Int) - a hour number.
|
||||
func DateHour(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// DateLeapYear returns true if date is in a leap year else false.
|
||||
// DATE_LEAPYEAR returns true if date is in a leap year else false.
|
||||
// @params date (DateTime) - source DateTime.
|
||||
// @return (Boolean) - date is in a leap year.
|
||||
func DateLeapYear(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
|
@ -7,6 +7,7 @@ func RegisterLib(ns core.Namespace) error {
|
||||
core.NewFunctionsFromMap(map[string]core.Function{
|
||||
"NOW": Now,
|
||||
"DATE": Date,
|
||||
"DATE_COMPARE": DateCompare,
|
||||
"DATE_DAYOFWEEK": DateDayOfWeek,
|
||||
"DATE_YEAR": DateYear,
|
||||
"DATE_MONTH": DateMonth,
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// DateMillisecond returns the millisecond of date as a number.
|
||||
// DATE_MILLISECOND returns the millisecond of date as a number.
|
||||
// @params date (DateTime) - source DateTime.
|
||||
// @return (Int) - a millisecond number.
|
||||
func DateMillisecond(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// DateMinute returns the minute of date as a number.
|
||||
// DATE_MINUTE returns the minute of date as a number.
|
||||
// @params date (DateTime) - source DateTime.
|
||||
// @return (Int) - a minute number.
|
||||
func DateMinute(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// DateMonth returns the month of date as a number.
|
||||
// DATE_MONTH returns the month of date as a number.
|
||||
// @params date (DateTime) - source DateTime.
|
||||
// @return (Int) - a month number.
|
||||
func DateMonth(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/core"
|
||||
)
|
||||
|
||||
// Now returns new DateTime object with Time equal to time.Now().
|
||||
// NOW returns new DateTime object with Time equal to time.Now().
|
||||
// @returns (DateTime) - New DateTime object.
|
||||
func Now(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 0, 0)
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// DateQuarter returns which quarter date belongs to.
|
||||
// DATE_QUARTER returns which quarter date belongs to.
|
||||
// @params date (DateTime) - source DateTime.
|
||||
// @return (Int) - a quarter number.
|
||||
func DateQuarter(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// DateSecond returns the second of date as a number.
|
||||
// DATE_SECOND returns the second of date as a number.
|
||||
// @params date (DateTime) - source DateTime.
|
||||
// @return (Int) - a second number.
|
||||
func DateSecond(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// DateYear returns the year extracted from the given date.
|
||||
// DATE_YEAR returns the year extracted from the given date.
|
||||
// @params date (DateTime) - source DateTime.
|
||||
// @return (Int) - a year number.
|
||||
func DateYear(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user