-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9c1efe6
commit 97ec625
Showing
12 changed files
with
390 additions
and
4 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
hope-core/src/main/java/io/appform/hope/core/functions/impl/date/DayOfMonth.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2019. Santanu Sinha | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in | ||
* compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is | ||
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package io.appform.hope.core.functions.impl.date; | ||
|
||
import io.appform.hope.core.functions.FunctionImplementation; | ||
import io.appform.hope.core.functions.HopeFunction; | ||
import io.appform.hope.core.values.NumericValue; | ||
import io.appform.hope.core.visitors.Evaluator; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
/** | ||
* returns the current day of the month as a NumericValue. | ||
*/ | ||
@FunctionImplementation("datetime.day_of_month") | ||
public class DayOfMonth extends HopeFunction<NumericValue> { | ||
@Override | ||
public NumericValue apply(Evaluator.EvaluationContext evaluationContext) { | ||
return new NumericValue(LocalDateTime.now().getDayOfMonth()); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
hope-core/src/main/java/io/appform/hope/core/functions/impl/date/DayOfWeek.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2019. Santanu Sinha | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in | ||
* compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is | ||
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package io.appform.hope.core.functions.impl.date; | ||
|
||
import io.appform.hope.core.functions.FunctionImplementation; | ||
import io.appform.hope.core.functions.HopeFunction; | ||
import io.appform.hope.core.values.NumericValue; | ||
import io.appform.hope.core.visitors.Evaluator; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
/** | ||
* returns the current day of the week as a NumericValue. | ||
*/ | ||
@FunctionImplementation("datetime.day_of_week") | ||
public class DayOfWeek extends HopeFunction<NumericValue> { | ||
@Override | ||
public NumericValue apply(Evaluator.EvaluationContext evaluationContext) { | ||
return new NumericValue(LocalDateTime.now().getDayOfWeek().getValue()); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
hope-core/src/main/java/io/appform/hope/core/functions/impl/date/DayOfYear.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2019. Santanu Sinha | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in | ||
* compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is | ||
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package io.appform.hope.core.functions.impl.date; | ||
|
||
import io.appform.hope.core.functions.FunctionImplementation; | ||
import io.appform.hope.core.functions.HopeFunction; | ||
import io.appform.hope.core.values.NumericValue; | ||
import io.appform.hope.core.visitors.Evaluator; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
/** | ||
* returns the current day of the year as a NumericValue. | ||
*/ | ||
@FunctionImplementation("datetime.day_of_year") | ||
public class DayOfYear extends HopeFunction<NumericValue> { | ||
@Override | ||
public NumericValue apply(Evaluator.EvaluationContext evaluationContext) { | ||
return new NumericValue(LocalDateTime.now().getDayOfYear()); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
hope-core/src/main/java/io/appform/hope/core/functions/impl/date/HourOfDay.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2019. Santanu Sinha | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in | ||
* compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is | ||
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package io.appform.hope.core.functions.impl.date; | ||
|
||
import io.appform.hope.core.functions.FunctionImplementation; | ||
import io.appform.hope.core.functions.HopeFunction; | ||
import io.appform.hope.core.values.NumericValue; | ||
import io.appform.hope.core.visitors.Evaluator; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
/** | ||
* Returns the current hour of the day as a NumericValue. | ||
*/ | ||
@FunctionImplementation("datetime.hour_of_day") | ||
public class HourOfDay extends HopeFunction<NumericValue> { | ||
@Override | ||
public NumericValue apply(Evaluator.EvaluationContext evaluationContext) { | ||
return new NumericValue(LocalDateTime.now().getHour()); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
hope-core/src/main/java/io/appform/hope/core/functions/impl/date/MinuteOfHour.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2019. Santanu Sinha | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in | ||
* compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is | ||
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package io.appform.hope.core.functions.impl.date; | ||
|
||
import io.appform.hope.core.functions.FunctionImplementation; | ||
import io.appform.hope.core.functions.HopeFunction; | ||
import io.appform.hope.core.values.NumericValue; | ||
import io.appform.hope.core.visitors.Evaluator; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
/** | ||
* Returns the current minute of the hour as a NumericValue. | ||
*/ | ||
@FunctionImplementation("datetime.minute_of_hour") | ||
public class MinuteOfHour extends HopeFunction<NumericValue> { | ||
@Override | ||
public NumericValue apply(Evaluator.EvaluationContext evaluationContext) { | ||
return new NumericValue(LocalDateTime.now().getMinute()); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
hope-core/src/main/java/io/appform/hope/core/functions/impl/date/MonthOfYear.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright 2019. Santanu Sinha | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in | ||
* compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is | ||
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package io.appform.hope.core.functions.impl.date; | ||
|
||
import io.appform.hope.core.functions.FunctionImplementation; | ||
import io.appform.hope.core.functions.HopeFunction; | ||
import io.appform.hope.core.values.NumericValue; | ||
import io.appform.hope.core.visitors.Evaluator; | ||
|
||
import java.time.LocalDateTime; | ||
import java.time.temporal.WeekFields; | ||
import java.util.Locale; | ||
|
||
/** | ||
* returns the current month of the year as a NumericValue. | ||
*/ | ||
@FunctionImplementation("datetime.month_of_year") | ||
public class MonthOfYear extends HopeFunction<NumericValue> { | ||
@Override | ||
public NumericValue apply(Evaluator.EvaluationContext evaluationContext) { | ||
return new NumericValue(LocalDateTime.now().getMonth().getValue()); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
hope-core/src/main/java/io/appform/hope/core/functions/impl/date/Now.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright 2019. Santanu Sinha | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in | ||
* compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is | ||
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package io.appform.hope.core.functions.impl.date; | ||
|
||
import io.appform.hope.core.functions.FunctionImplementation; | ||
import io.appform.hope.core.functions.HopeFunction; | ||
import io.appform.hope.core.values.NumericValue; | ||
import io.appform.hope.core.visitors.Evaluator; | ||
|
||
/** | ||
* Returns current UNIX epoch time {@link NumericValue} in milliseconds. | ||
*/ | ||
@FunctionImplementation("datetime.now") | ||
public class Now extends HopeFunction<NumericValue> { | ||
@Override | ||
public NumericValue apply(Evaluator.EvaluationContext evaluationContext) { | ||
return new NumericValue(System.currentTimeMillis()); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
hope-core/src/main/java/io/appform/hope/core/functions/impl/date/SecondOfMinute.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2019. Santanu Sinha | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in | ||
* compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is | ||
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package io.appform.hope.core.functions.impl.date; | ||
|
||
import io.appform.hope.core.functions.FunctionImplementation; | ||
import io.appform.hope.core.functions.HopeFunction; | ||
import io.appform.hope.core.values.NumericValue; | ||
import io.appform.hope.core.visitors.Evaluator; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
/** | ||
* Returns the current second of the minute as a NumericValue. | ||
*/ | ||
@FunctionImplementation("datetime.second_of_minute") | ||
public class SecondOfMinute extends HopeFunction<NumericValue> { | ||
@Override | ||
public NumericValue apply(Evaluator.EvaluationContext evaluationContext) { | ||
return new NumericValue(LocalDateTime.now().getSecond()); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
hope-core/src/main/java/io/appform/hope/core/functions/impl/date/WeekOfMonth.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright 2019. Santanu Sinha | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in | ||
* compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is | ||
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package io.appform.hope.core.functions.impl.date; | ||
|
||
import io.appform.hope.core.functions.FunctionImplementation; | ||
import io.appform.hope.core.functions.HopeFunction; | ||
import io.appform.hope.core.values.NumericValue; | ||
import io.appform.hope.core.visitors.Evaluator; | ||
|
||
import java.time.LocalDateTime; | ||
import java.time.temporal.WeekFields; | ||
import java.util.Locale; | ||
|
||
/** | ||
* returns the current week of the month as a NumericValue. | ||
*/ | ||
@FunctionImplementation("datetime.week_of_month") | ||
public class WeekOfMonth extends HopeFunction<NumericValue> { | ||
@Override | ||
public NumericValue apply(Evaluator.EvaluationContext evaluationContext) { | ||
return new NumericValue(LocalDateTime.now().get(WeekFields.of(Locale.getDefault()).weekOfMonth())); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
hope-core/src/main/java/io/appform/hope/core/functions/impl/date/WeekOfYear.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright 2019. Santanu Sinha | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in | ||
* compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is | ||
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package io.appform.hope.core.functions.impl.date; | ||
|
||
import io.appform.hope.core.functions.FunctionImplementation; | ||
import io.appform.hope.core.functions.HopeFunction; | ||
import io.appform.hope.core.values.NumericValue; | ||
import io.appform.hope.core.visitors.Evaluator; | ||
|
||
import java.time.LocalDateTime; | ||
import java.time.temporal.WeekFields; | ||
import java.util.Locale; | ||
|
||
/** | ||
* returns the current week of the year as a NumericValue. | ||
*/ | ||
@FunctionImplementation("datetime.week_of_year") | ||
public class WeekOfYear extends HopeFunction<NumericValue> { | ||
@Override | ||
public NumericValue apply(Evaluator.EvaluationContext evaluationContext) { | ||
return new NumericValue(LocalDateTime.now().get(WeekFields.of(Locale.getDefault()).weekOfYear())); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
hope-core/src/main/java/io/appform/hope/core/functions/impl/date/Year.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2019. Santanu Sinha | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in | ||
* compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is | ||
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package io.appform.hope.core.functions.impl.date; | ||
|
||
import io.appform.hope.core.functions.FunctionImplementation; | ||
import io.appform.hope.core.functions.HopeFunction; | ||
import io.appform.hope.core.values.NumericValue; | ||
import io.appform.hope.core.visitors.Evaluator; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
/** | ||
* returns the current year as a NumericValue. | ||
*/ | ||
@FunctionImplementation("datetime.year") | ||
public class Year extends HopeFunction<NumericValue> { | ||
@Override | ||
public NumericValue apply(Evaluator.EvaluationContext evaluationContext) { | ||
return new NumericValue(LocalDateTime.now().getYear()); | ||
} | ||
} |
Oops, something went wrong.