Skip to content

Commit

Permalink
Added basic time-related classes for usage in script and ruled (openh…
Browse files Browse the repository at this point in the history
…ab#2587)

Signed-off-by: Christoph Weitkamp <[email protected]>
GitOrigin-RevId: 793ced6
  • Loading branch information
cweitkamp authored and splatch committed Jul 12, 2023
1 parent a8d601c commit c9ec53f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Duration;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
Expand Down Expand Up @@ -147,12 +151,18 @@ public DefaultScriptScopeProvider(final @Reference ItemRegistry itemRegistry,
elements.put("PointType", PointType.class);
elements.put("StringType", StringType.class);

elements.put("SIUnits", SIUnits.class);
elements.put("ImperialUnits", ImperialUnits.class);
elements.put("MetricPrefix", MetricPrefix.class);
elements.put("SIUnits", SIUnits.class);
elements.put("Units", Units.class);
elements.put("BinaryPrefix", BinaryPrefix.class);

// date time static functions
elements.put("ChronoUnit", ChronoUnit.class);
elements.put("Duration", Duration.class);
elements.put("ZoneId", ZoneId.class);
elements.put("ZonedDateTime", ZonedDateTime.class);

// services
elements.put("items", new ItemRegistryDelegate(itemRegistry));
elements.put("ir", itemRegistry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.URLEncoder;
import java.time.Duration;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -100,6 +103,9 @@ protected List<Class<?>> getStaticImportClasses() {
result.add(BinaryPrefix.class);

// date time static functions
result.add(ChronoUnit.class);
result.add(Duration.class);
result.add(ZoneId.class);
result.add(ZonedDateTime.class);

result.addAll(getActionClasses());
Expand Down

0 comments on commit c9ec53f

Please sign in to comment.