betweenTimes is not a function

Using the JS Scripting addon, running this code

console.log(time.toZDT().betweenTimes('22:00', '05:00'))

gives an error

org.graalvm.polyglot.PolyglotException: TypeError: (intermediate value).toZDT(...).betweenTimes is not a function
	at <js>.:program(<eval>:10) ~[?:?]
	at org.graalvm.polyglot.Context.eval( ~[?:?]

I have many other JS Scripting rules, both UI and file based, running successfully.
Similar functions like toToday() and isClose() work OK

The problem was noticed on 3.4.0.M2 and having tried clear-cache, reboot etc then upgraded to M3.
As a side note the upgrade to M4 does not work for me because of

Has anybody else seen this?

  • Platform information:
    • Hardware: RPI4 8G
    • OS: Raspbian GNU/Linux 10 (buster). OpenHABian
    • Java Runtime Environment: openjdk 11.0.16
    • openHAB version: 3.4.0.M3

The function actually is isBetweenTimes, not betweenTimes. The docs were wrong, this was corrected in [docs] changing betweenTimes to isBetweenTimes in docs by rkoshak · Pull Request #149 · openhab/openhab-js · GitHub.

FYI what this error messages means:
The error is no error related to GraalJS or the addon not working correctly.
The problem is, that the called function does not exist.

1 Like

Thank you.

Can you please mark this as solved?
There should be a checkbox at the bottom of each message.