Added basic time-related classes for usage in script and ruled (#2587)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>pull/2605/head
parent
f641d1d6ec
commit
793ced6286
|
@ -17,6 +17,10 @@ import java.net.URLEncoder;
|
|||
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;
|
||||
|
@ -147,12 +151,18 @@ public class DefaultScriptScopeProvider implements ScriptExtensionProvider {
|
|||
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);
|
||||
|
|
|
@ -15,7 +15,10 @@ package org.openhab.core.model.script.scoping;
|
|||
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;
|
||||
|
||||
|
@ -100,6 +103,9 @@ public class ScriptImplicitlyImportedTypes extends ImplicitlyImportedFeatures {
|
|||
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());
|
||||
|
|
Loading…
Reference in New Issue