Skip to content

Commit

Permalink
Added basic time-related classes for usage in script and ruled (#2587)
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
  • Loading branch information
cweitkamp committed Dec 10, 2021
1 parent f641d1d commit 793ced6
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 793ced6

Please sign in to comment.