Skip to content

Commit

Permalink
Renamed "datetime" function implementations to "date"
Browse files Browse the repository at this point in the history
  • Loading branch information
Tushar-Naik committed Jan 10, 2024
1 parent 97ec625 commit 171e509
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/**
* returns the current day of the month as a NumericValue.
*/
@FunctionImplementation("datetime.day_of_month")
@FunctionImplementation("date.day_of_month")
public class DayOfMonth extends HopeFunction<NumericValue> {
@Override
public NumericValue apply(Evaluator.EvaluationContext evaluationContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/**
* returns the current day of the week as a NumericValue.
*/
@FunctionImplementation("datetime.day_of_week")
@FunctionImplementation("date.day_of_week")
public class DayOfWeek extends HopeFunction<NumericValue> {
@Override
public NumericValue apply(Evaluator.EvaluationContext evaluationContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/**
* returns the current day of the year as a NumericValue.
*/
@FunctionImplementation("datetime.day_of_year")
@FunctionImplementation("date.day_of_year")
public class DayOfYear extends HopeFunction<NumericValue> {
@Override
public NumericValue apply(Evaluator.EvaluationContext evaluationContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/**
* Returns the current hour of the day as a NumericValue.
*/
@FunctionImplementation("datetime.hour_of_day")
@FunctionImplementation("date.hour_of_day")
public class HourOfDay extends HopeFunction<NumericValue> {
@Override
public NumericValue apply(Evaluator.EvaluationContext evaluationContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/**
* Returns the current minute of the hour as a NumericValue.
*/
@FunctionImplementation("datetime.minute_of_hour")
@FunctionImplementation("date.minute_of_hour")
public class MinuteOfHour extends HopeFunction<NumericValue> {
@Override
public NumericValue apply(Evaluator.EvaluationContext evaluationContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/**
* returns the current month of the year as a NumericValue.
*/
@FunctionImplementation("datetime.month_of_year")
@FunctionImplementation("date.month_of_year")
public class MonthOfYear extends HopeFunction<NumericValue> {
@Override
public NumericValue apply(Evaluator.EvaluationContext evaluationContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/**
* Returns current UNIX epoch time {@link NumericValue} in milliseconds.
*/
@FunctionImplementation("datetime.now")
@FunctionImplementation("date.now")
public class Now extends HopeFunction<NumericValue> {
@Override
public NumericValue apply(Evaluator.EvaluationContext evaluationContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/**
* Returns the current second of the minute as a NumericValue.
*/
@FunctionImplementation("datetime.second_of_minute")
@FunctionImplementation("date.second_of_minute")
public class SecondOfMinute extends HopeFunction<NumericValue> {
@Override
public NumericValue apply(Evaluator.EvaluationContext evaluationContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/**
* returns the current week of the month as a NumericValue.
*/
@FunctionImplementation("datetime.week_of_month")
@FunctionImplementation("date.week_of_month")
public class WeekOfMonth extends HopeFunction<NumericValue> {
@Override
public NumericValue apply(Evaluator.EvaluationContext evaluationContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/**
* returns the current week of the year as a NumericValue.
*/
@FunctionImplementation("datetime.week_of_year")
@FunctionImplementation("date.week_of_year")
public class WeekOfYear extends HopeFunction<NumericValue> {
@Override
public NumericValue apply(Evaluator.EvaluationContext evaluationContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/**
* returns the current year as a NumericValue.
*/
@FunctionImplementation("datetime.year")
@FunctionImplementation("date.year")
public class Year extends HopeFunction<NumericValue> {
@Override
public NumericValue apply(Evaluator.EvaluationContext evaluationContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,17 +242,17 @@ private static Stream<Arguments> rules() {
Arguments.of("{ \"array\" : [1,2,3, 4,8,16] }","arr.len(\"/array\") == 6", true),
Arguments.of("{ \"array\" : [1,2,3, 4,8,16] }","arr.len('/array') == 6", true),

Arguments.of("{}", "math.sub(datetime.now(), %d) <= 1000 && math.sub(datetime.now(), %d) >= 0".formatted(epochMilli, epochMilli), true),
Arguments.of("{}", "math.sub(datetime.second_of_minute(), %d) <= 1 && math.sub(datetime.second_of_minute(), %d) >= 0".formatted(dateTime.getSecond(), dateTime.getSecond()), true),
Arguments.of("{}", "math.sub(datetime.minute_of_hour(), %d) <= 1 && math.sub(datetime.minute_of_hour(), %d) >= 0".formatted(dateTime.getMinute(), dateTime.getMinute()), true),
Arguments.of("{}", "math.sub(datetime.hour_of_day(), %d) <= 1 && math.sub(datetime.hour_of_day(), %d) >= 0".formatted(dateTime.getHour(), dateTime.getHour()), true),
Arguments.of("{}", "math.sub(datetime.day_of_week(), %d) <= 1 && math.sub(datetime.day_of_week(), %d) >= 0".formatted(dateTime.getDayOfWeek().getValue(), dateTime.getDayOfWeek().getValue()), true),
Arguments.of("{}", "math.sub(datetime.day_of_month(), %d) <= 1 && math.sub(datetime.day_of_month(), %d) >= 0".formatted(dateTime.getDayOfMonth(), dateTime.getDayOfMonth()), true),
Arguments.of("{}", "math.sub(datetime.day_of_year(), %d) <= 1 && math.sub(datetime.day_of_year(), %d) >= 0".formatted(dateTime.getDayOfYear(), dateTime.getDayOfYear()), true),
Arguments.of("{}", "math.sub(datetime.week_of_month(), %d) <= 1 && math.sub(datetime.week_of_month(), %d) >= 0".formatted(weekOfMonth, weekOfMonth), true),
Arguments.of("{}", "math.sub(datetime.week_of_year(), %d) <= 1 && math.sub(datetime.week_of_year(), %d) >= 0".formatted(weekOfYear, weekOfYear), true),
Arguments.of("{}", "math.sub(datetime.month_of_year(), %d) <= 1 && math.sub(datetime.month_of_year(), %d) >= 0".formatted(dateTime.getMonth().getValue(), dateTime.getMonth().getValue()), true),
Arguments.of("{}", "math.sub(datetime.year(), %d) <= 1 && math.sub(datetime.year(), %d) >= 0".formatted(dateTime.getYear(), dateTime.getYear()), true)
Arguments.of("{}", "math.sub(date.now(), %d) <= 2000 && math.sub(date.now(), %d) >= 0".formatted(epochMilli, epochMilli), true),
Arguments.of("{}", "math.sub(date.second_of_minute(), %d) <= 1 && math.sub(date.second_of_minute(), %d) >= 0".formatted(dateTime.getSecond(), dateTime.getSecond()), true),
Arguments.of("{}", "math.sub(date.minute_of_hour(), %d) <= 1 && math.sub(date.minute_of_hour(), %d) >= 0".formatted(dateTime.getMinute(), dateTime.getMinute()), true),
Arguments.of("{}", "math.sub(date.hour_of_day(), %d) <= 1 && math.sub(date.hour_of_day(), %d) >= 0".formatted(dateTime.getHour(), dateTime.getHour()), true),
Arguments.of("{}", "math.sub(date.day_of_week(), %d) <= 1 && math.sub(date.day_of_week(), %d) >= 0".formatted(dateTime.getDayOfWeek().getValue(), dateTime.getDayOfWeek().getValue()), true),
Arguments.of("{}", "math.sub(date.day_of_month(), %d) <= 1 && math.sub(date.day_of_month(), %d) >= 0".formatted(dateTime.getDayOfMonth(), dateTime.getDayOfMonth()), true),
Arguments.of("{}", "math.sub(date.day_of_year(), %d) <= 1 && math.sub(date.day_of_year(), %d) >= 0".formatted(dateTime.getDayOfYear(), dateTime.getDayOfYear()), true),
Arguments.of("{}", "math.sub(date.week_of_month(), %d) <= 1 && math.sub(date.week_of_month(), %d) >= 0".formatted(weekOfMonth, weekOfMonth), true),
Arguments.of("{}", "math.sub(date.week_of_year(), %d) <= 1 && math.sub(date.week_of_year(), %d) >= 0".formatted(weekOfYear, weekOfYear), true),
Arguments.of("{}", "math.sub(date.month_of_year(), %d) <= 1 && math.sub(date.month_of_year(), %d) >= 0".formatted(dateTime.getMonth().getValue(), dateTime.getMonth().getValue()), true),
Arguments.of("{}", "math.sub(date.year(), %d) <= 1 && math.sub(date.year(), %d) >= 0".formatted(dateTime.getYear(), dateTime.getYear()), true)

);
}
Expand Down

0 comments on commit 171e509

Please sign in to comment.