How to compute duration from timeRangeStart and timeRangeStop

Hello,

I’m playing with experimental function oee, and I would like to feed the plannedTime parameter with the duration from timeRangeStart and timeRangeStop

I’ve tried different thing without success

time1 = uint(v: v.timeRangeStart)
time2 = uint(v: v.timeRangeStop)
time = duration(v: time2 - time1)

Result availability is incorrect (time seems too big)
Here is the debug values of time1 and 2 with a period of 12h

18446700873709552000

1646212749026256100

Also I tried to give directly v.windowPeriod,

  |> oee.APQ(
    runningState: "Running",
    plannedTime: v.windowPeriod,
    idealCycleTime: 900ms
  )

But then values of availability is too big, meaning the time range is too small.

I’m sure there is a way to compute this duration, but I cannot figure it out…

Tks
Cyril

I’ve tested the code from grafana and there it works fine. However from influx UI it’s not correct

time1 = uint(v: v.timeRangeStart)
time2 = uint(v: v.timeRangeStop)
time = duration(v: time2 - time1)