1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-04-23 12:18:46 +02:00

Added missed DATE_COMPARE and updated comments (#537)

This commit is contained in:
Tim Voronov 2020-07-13 15:39:33 -04:00 committed by GitHub
parent 213f9b1fd6
commit 42cf623471
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 20 additions and 19 deletions

View File

@ -14,7 +14,7 @@ var (
emptyString values.String 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 date (DateTime) - source date.
// @params amount (Int) - amount of units // @params amount (Int) - amount of units
// @params unit (String) - unit. // @params unit (String) - unit.
@ -44,7 +44,7 @@ func DateAdd(_ context.Context, args ...core.Value) (core.Value, error) {
return values.NewDateTime(tm), nil 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 date (DateTime) - source date.
// @params amount (Int) - amount of units // @params amount (Int) - amount of units
// @params unit (String) - unit. // @params unit (String) - unit.

View File

@ -9,7 +9,7 @@ import (
"github.com/pkg/errors" "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 date1, date2 (DateTime) - comparable dates.
// @params unitRangeStart (String) - unit to start from. // @params unitRangeStart (String) - unit to start from.
// @params unitRangeEnd (String, Optional) - unit to end with. // @params unitRangeEnd (String, Optional) - unit to end with.

View File

@ -9,7 +9,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types" "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. // @params timeString (String) - string in RFC3339 format.
// @return (DateTime) - new DateTime object derived from timeString. // @return (DateTime) - new DateTime object derived from timeString.
func Date(_ context.Context, args ...core.Value) (core.Value, error) { func Date(_ context.Context, args ...core.Value) (core.Value, error) {

View File

@ -8,7 +8,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types" "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. // @params date (DateTime) - source DateTime.
// @return (Int) - a day number. // @return (Int) - a day number.
func DateDay(_ context.Context, args ...core.Value) (core.Value, error) { func DateDay(_ context.Context, args ...core.Value) (core.Value, error) {

View File

@ -8,7 +8,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types" "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. // @params date (DateTime) - source DateTime.
// @return (Int) - return number of the weekday. // @return (Int) - return number of the weekday.
func DateDayOfWeek(_ context.Context, args ...core.Value) (core.Value, error) { func DateDayOfWeek(_ context.Context, args ...core.Value) (core.Value, error) {

View File

@ -8,7 +8,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types" "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). // The return value range from 1 to 365 (366 in a leap year).
// @params date (DateTime) - source DateTime. // @params date (DateTime) - source DateTime.
// @return (Int) - a day of year number. // @return (Int) - a day of year number.

View File

@ -24,7 +24,7 @@ var daysCount = map[time.Month]int{
time.December: 31, 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. // @params date (DateTime) - source DateTime.
// @return (Int) - number of the days. // @return (Int) - number of the days.
func DateDaysInMonth(_ context.Context, args ...core.Value) (core.Value, error) { func DateDaysInMonth(_ context.Context, args ...core.Value) (core.Value, error) {

View File

@ -8,7 +8,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types" "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 date1 (DateTime) - first DateTime.
// @params date2 (DateTime) - second DateTime. // @params date2 (DateTime) - second DateTime.
// @params unit (String) - time unit to return the difference in. // @params unit (String) - time unit to return the difference in.

View File

@ -8,7 +8,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types" "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. // @params date (DateTime) - source DateTime object.
// @return (String) - formatted date. // @return (String) - formatted date.
func DateFormat(_ context.Context, args ...core.Value) (core.Value, error) { func DateFormat(_ context.Context, args ...core.Value) (core.Value, error) {

View File

@ -8,7 +8,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types" "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. // @params date (DateTime) - source DateTime.
// @return (Int) - a hour number. // @return (Int) - a hour number.
func DateHour(_ context.Context, args ...core.Value) (core.Value, error) { func DateHour(_ context.Context, args ...core.Value) (core.Value, error) {

View File

@ -8,7 +8,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types" "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. // @params date (DateTime) - source DateTime.
// @return (Boolean) - date is in a leap year. // @return (Boolean) - date is in a leap year.
func DateLeapYear(_ context.Context, args ...core.Value) (core.Value, error) { func DateLeapYear(_ context.Context, args ...core.Value) (core.Value, error) {

View File

@ -7,6 +7,7 @@ func RegisterLib(ns core.Namespace) error {
core.NewFunctionsFromMap(map[string]core.Function{ core.NewFunctionsFromMap(map[string]core.Function{
"NOW": Now, "NOW": Now,
"DATE": Date, "DATE": Date,
"DATE_COMPARE": DateCompare,
"DATE_DAYOFWEEK": DateDayOfWeek, "DATE_DAYOFWEEK": DateDayOfWeek,
"DATE_YEAR": DateYear, "DATE_YEAR": DateYear,
"DATE_MONTH": DateMonth, "DATE_MONTH": DateMonth,

View File

@ -8,7 +8,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types" "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. // @params date (DateTime) - source DateTime.
// @return (Int) - a millisecond number. // @return (Int) - a millisecond number.
func DateMillisecond(_ context.Context, args ...core.Value) (core.Value, error) { func DateMillisecond(_ context.Context, args ...core.Value) (core.Value, error) {

View File

@ -8,7 +8,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types" "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. // @params date (DateTime) - source DateTime.
// @return (Int) - a minute number. // @return (Int) - a minute number.
func DateMinute(_ context.Context, args ...core.Value) (core.Value, error) { func DateMinute(_ context.Context, args ...core.Value) (core.Value, error) {

View File

@ -8,7 +8,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types" "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. // @params date (DateTime) - source DateTime.
// @return (Int) - a month number. // @return (Int) - a month number.
func DateMonth(_ context.Context, args ...core.Value) (core.Value, error) { func DateMonth(_ context.Context, args ...core.Value) (core.Value, error) {

View File

@ -8,7 +8,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/core" "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. // @returns (DateTime) - New DateTime object.
func Now(_ context.Context, args ...core.Value) (core.Value, error) { func Now(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 0, 0) err := core.ValidateArgs(args, 0, 0)

View File

@ -9,7 +9,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types" "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. // @params date (DateTime) - source DateTime.
// @return (Int) - a quarter number. // @return (Int) - a quarter number.
func DateQuarter(_ context.Context, args ...core.Value) (core.Value, error) { func DateQuarter(_ context.Context, args ...core.Value) (core.Value, error) {

View File

@ -8,7 +8,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types" "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. // @params date (DateTime) - source DateTime.
// @return (Int) - a second number. // @return (Int) - a second number.
func DateSecond(_ context.Context, args ...core.Value) (core.Value, error) { func DateSecond(_ context.Context, args ...core.Value) (core.Value, error) {

View File

@ -8,7 +8,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types" "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. // @params date (DateTime) - source DateTime.
// @return (Int) - a year number. // @return (Int) - a year number.
func DateYear(_ context.Context, args ...core.Value) (core.Value, error) { func DateYear(_ context.Context, args ...core.Value) (core.Value, error) {