yesamer commented on code in PR #6394:
URL: 
https://github.com/apache/incubator-kie-drools/pull/6394#discussion_r2194323526


##########
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/util/EvalHelper.java:
##########
@@ -167,6 +179,19 @@ public static PropertyValueResult getDefinedValue(final 
Object current, final St
                 case "weekday":
                     result = ((TemporalAccessor) 
current).get(ChronoField.DAY_OF_WEEK);
                     break;
+                case "value":
+                    result = null;
+                    if (current instanceof LocalTime) {
+                        result = BigDecimal.valueOf(((LocalTime) 
current).toSecondOfDay());
+                    } else if (current instanceof OffsetTime) {
+                        result = BigDecimal.valueOf(((OffsetTime) 
current).toLocalTime().toSecondOfDay());
+                    } else if (current instanceof LocalDate date) {
+                        ZonedDateTime dtAtMidnightUTC = 
date.atStartOfDay(ZoneOffset.UTC);
+                        result = 
BigDecimal.valueOf(dtAtMidnightUTC.toEpochSecond());
+                    } else if (current instanceof ZonedDateTime) {
+                        result = BigDecimal.valueOf(((ZonedDateTime) 
current).toEpochSecond());
+                    }
+                    break;

Review Comment:
   @AthiraHari77 Can you please add the at least one test for any single `if` 
branch? eg. it seems to me the first `if` is not covered. Thanks



##########
kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELDateTimeDurationTest.java:
##########
@@ -280,25 +281,31 @@ private static Collection<Object[]> data() {
                 { "date and time(\"2016-07-29T05:48:23.765-05:00\").time 
offset", Duration.parse( "PT-5H" ), null},
                 { "date and 
time(\"2018-12-10T10:30:00@Europe/Rome\").timezone", "Europe/Rome", null},
                 { "date and time(\"2018-12-10T10:30:00@Etc/UTC\").timezone", 
"Etc/UTC", null},
+                { "date and time(\"2016-07-29T05:48:23.765-05:00\").value", 
BigDecimal.valueOf(1469789303) , null},
+                { "date and time(\"2025-07-08T10:00:00Z\").value", 
BigDecimal.valueOf(1751968800) , null},
                 { "time(\"13:20:00-05:00\").hour", BigDecimal.valueOf( 13 ), 
null},
                 { "time(\"13:20:00-05:00\").minute", BigDecimal.valueOf( 20 ), 
null},
                 { "time(\"13:20:00-05:00\").second", BigDecimal.valueOf( 0 ), 
null},
                 { "time(\"13:20:00-05:00\").time offset", Duration.parse( 
"PT-5H" ), null},
                 { "time(\"13:20:00@Europe/Rome\").timezone", "Europe/Rome" , 
null},
                 { "time(\"13:20:00@Etc/UTC\").timezone", "Etc/UTC" , null},
                 { "time(\"13:20:00@Etc/GMT\").timezone", "Etc/GMT" , null},
+                { "time(\"13:20:00-05:00\").value", BigDecimal.valueOf(48000), 
null},
                 { "duration( \"P2DT20H14M\" ).days", BigDecimal.valueOf(2) , 
null},
                 { "duration( \"P2DT20H14M\" ).hours", BigDecimal.valueOf(20) , 
null},
                 { "duration( \"P2DT20H14M\" ).minutes", BigDecimal.valueOf(14) 
, null},
                 { "duration( \"P2DT20H14M5S\" ).seconds", 
BigDecimal.valueOf(5) , null},
+                { "duration( \"P1DT1H\" ).value", BigDecimal.valueOf(90000) , 
null},
                 { "duration(\"P1Y\").years", BigDecimal.valueOf(1) , null},
                 { "duration(\"P1Y\").months", BigDecimal.valueOf(0) , null},
                 { "duration(\"P1Y\").days", null , null},
                 { "duration(\"P1Y\").hours", null , null},
                 { "duration(\"P1Y\").minutes", null , null},
                 { "duration(\"P1Y\").seconds", null , null},
-                { "years and months duration( date(\"2011-12-22\"), 
date(\"2013-08-24\") ).years", BigDecimal.valueOf(1) , null},
-                { "years and months duration( date(\"2011-12-22\"), 
date(\"2013-08-24\") ).months", BigDecimal.valueOf(8) , null},
+                { "duration(\"P1Y1M\").value", BigDecimal.valueOf(13) , null},
+                { "years and months duration( date(\"2011-12-22\"), 
date(\"2013-08-24\") ).years", BigDecimal.valueOf(1), null},
+                { "years and months duration( date(\"2011-12-22\"), 
date(\"2013-08-24\") ).months", BigDecimal.valueOf(8), null},

Review Comment:
   @gitgabrio That duration is composed by 1 year and 8 months



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to