openhab / openhab-js

openHAB JavaScript Library for JavaScript Scripting Automation
https://www.openhab.org/addons/automation/jsscripting/
Eclipse Public License 2.0
38 stars 31 forks source link

time.isBetweenTimes cannot see time.toZDT() #150

Closed rkoshak closed 1 year ago

rkoshak commented 1 year ago

Expected Behavior

When calling myZDT.isBetweenTimes(before, after) I expect to get back a boolean.

Current Behavior

An error is thrown:

an error occured: TypeError: time.toZDT is not a function

I know this worked when I checked it in because I had test cases to exercise it. But I can't see anything that has changed in time.js since then to cause it to break.

Possible Solution

I don't understand the problem yet so I've no idea how to fix it. Clearly there is something going on that is making it invisible to the isBetweenTimes function.

Steps to Reproduce (for Bugs)

  1. Create a ZonedDateTime. I use time.toZDT() just to prove to myself that there is nothing wrong with time.toZDT(). Let's name it myTime.
  2. Call myTime.isBetweenTimes("06:00:00", "12:00:00") or just about anything that toZDT supports.
  3. See the error in the logs.

Context

Your Environment

florian-h05 commented 1 year ago

@rkoshak

I know what‘s the problem:

Since my PR #137, toZDT is no property of time in time.js. Anyway, you can call time.toZDT because toZDT is seperately exported with module.exports. I changed this because otherwise typescript was not able to generate type definitions for toZDT, sorry.

I fixed that, you might have seen the commit which links to this issue.

As I am not at home and currently can‘t try out myself, so it would be cool if you could verify that it works. Just run npm install git+https://github.com/florian-h05/openhab-js.git#issue-150 in OPENHAB_CONF/automation/js.

I‘ll open a PR; please give an approval review if it works.