From 171e5097f4fc78252de534145b5e7ac96326514c Mon Sep 17 00:00:00 2001 From: Tushar Naik Date: Wed, 10 Jan 2024 09:59:53 +0530 Subject: [PATCH] Renamed "datetime" function implementations to "date" --- .../core/functions/impl/date/DayOfMonth.java | 2 +- .../core/functions/impl/date/DayOfWeek.java | 2 +- .../core/functions/impl/date/DayOfYear.java | 2 +- .../core/functions/impl/date/HourOfDay.java | 2 +- .../functions/impl/date/MinuteOfHour.java | 2 +- .../core/functions/impl/date/MonthOfYear.java | 2 +- .../hope/core/functions/impl/date/Now.java | 2 +- .../functions/impl/date/SecondOfMinute.java | 2 +- .../core/functions/impl/date/WeekOfMonth.java | 2 +- .../core/functions/impl/date/WeekOfYear.java | 2 +- .../hope/core/functions/impl/date/Year.java | 2 +- .../hope/lang/LibraryFunctionsTest.java | 22 +++++++++---------- 12 files changed, 22 insertions(+), 22 deletions(-) diff --git a/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/DayOfMonth.java b/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/DayOfMonth.java index f46fd63..b793c42 100644 --- a/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/DayOfMonth.java +++ b/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/DayOfMonth.java @@ -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 { @Override public NumericValue apply(Evaluator.EvaluationContext evaluationContext) { diff --git a/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/DayOfWeek.java b/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/DayOfWeek.java index 0d6b3fc..b23a8e1 100644 --- a/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/DayOfWeek.java +++ b/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/DayOfWeek.java @@ -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 { @Override public NumericValue apply(Evaluator.EvaluationContext evaluationContext) { diff --git a/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/DayOfYear.java b/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/DayOfYear.java index 87bd2c5..b44ccf4 100644 --- a/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/DayOfYear.java +++ b/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/DayOfYear.java @@ -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 { @Override public NumericValue apply(Evaluator.EvaluationContext evaluationContext) { diff --git a/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/HourOfDay.java b/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/HourOfDay.java index 94f5fd9..f16b8ed 100644 --- a/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/HourOfDay.java +++ b/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/HourOfDay.java @@ -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 { @Override public NumericValue apply(Evaluator.EvaluationContext evaluationContext) { diff --git a/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/MinuteOfHour.java b/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/MinuteOfHour.java index 3eba9e0..9630be6 100644 --- a/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/MinuteOfHour.java +++ b/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/MinuteOfHour.java @@ -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 { @Override public NumericValue apply(Evaluator.EvaluationContext evaluationContext) { diff --git a/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/MonthOfYear.java b/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/MonthOfYear.java index 8046d06..6b56dec 100644 --- a/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/MonthOfYear.java +++ b/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/MonthOfYear.java @@ -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 { @Override public NumericValue apply(Evaluator.EvaluationContext evaluationContext) { diff --git a/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/Now.java b/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/Now.java index a7c5c18..a53c662 100644 --- a/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/Now.java +++ b/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/Now.java @@ -22,7 +22,7 @@ /** * Returns current UNIX epoch time {@link NumericValue} in milliseconds. */ -@FunctionImplementation("datetime.now") +@FunctionImplementation("date.now") public class Now extends HopeFunction { @Override public NumericValue apply(Evaluator.EvaluationContext evaluationContext) { diff --git a/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/SecondOfMinute.java b/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/SecondOfMinute.java index ede2d21..cced19a 100644 --- a/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/SecondOfMinute.java +++ b/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/SecondOfMinute.java @@ -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 { @Override public NumericValue apply(Evaluator.EvaluationContext evaluationContext) { diff --git a/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/WeekOfMonth.java b/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/WeekOfMonth.java index b6d2597..e068fa4 100644 --- a/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/WeekOfMonth.java +++ b/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/WeekOfMonth.java @@ -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 { @Override public NumericValue apply(Evaluator.EvaluationContext evaluationContext) { diff --git a/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/WeekOfYear.java b/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/WeekOfYear.java index d5b6e76..b1710a5 100644 --- a/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/WeekOfYear.java +++ b/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/WeekOfYear.java @@ -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 { @Override public NumericValue apply(Evaluator.EvaluationContext evaluationContext) { diff --git a/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/Year.java b/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/Year.java index 0563e26..6d95d5c 100644 --- a/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/Year.java +++ b/hope-core/src/main/java/io/appform/hope/core/functions/impl/date/Year.java @@ -24,7 +24,7 @@ /** * returns the current year as a NumericValue. */ -@FunctionImplementation("datetime.year") +@FunctionImplementation("date.year") public class Year extends HopeFunction { @Override public NumericValue apply(Evaluator.EvaluationContext evaluationContext) { diff --git a/hope-lang/src/test/java/io/appform/hope/lang/LibraryFunctionsTest.java b/hope-lang/src/test/java/io/appform/hope/lang/LibraryFunctionsTest.java index 840fd89..96a0c10 100644 --- a/hope-lang/src/test/java/io/appform/hope/lang/LibraryFunctionsTest.java +++ b/hope-lang/src/test/java/io/appform/hope/lang/LibraryFunctionsTest.java @@ -242,17 +242,17 @@ private static Stream 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) ); }