bartbutenaers / node-red-contrib-interval-length

A Node Red node to measure the interval length between successive messages
Apache License 2.0
5 stars 2 forks source link

decimals #11

Open luciangpl opened 3 years ago

luciangpl commented 3 years ago

Hi,
As you can see on the picture below, for values higher than 10 min, it is adding decimals for seconds image This is how the node is configured: image

bartbutenaers commented 3 years ago

Hi @luciangpl, Thanks for reporting this issue! Unfortunately I have been away from development a few months due to a surgery. I have added your issue to my todo list, and I will come back to you as soon as possible. Bart

luciangpl commented 3 years ago

Thanks, take care!

bartbutenaers commented 3 years ago

Hi @luciangpl,

Sorry for the long delay, due to circumstances...

I don't think this has any to do with 10 minutes. When you have a look at your screenshot, you will see that you "can" also get decimals for timings below 10 minutes:

image

My node calculates the time difference in milliseconds, and then it converts the milliseconds to human readable text using the pretty-ms library. I have done some tests with this library, to convert hardcoded milliseconds to human readable text:

image

From the above tests, you can see you can get decimals for any interval length...

From this second test:

image

You will see that the last two digits are rounded by that library. So you have 1 chance on 10 to have seconds without decimals ...

I could solve that by changing their secondsdecimaldigits from 1 to 0, to see no decimals instead of 1. However I don't know whether I will break existing flows that use those decimals already. Not sure ...

It would have been better if I had enabled their formatsubmilliseconds setting from the start. Then the output would also have contained ms values. But that is also a bit late now...

Any thoughts?

luciangpl commented 3 years ago

Hi Bart, I'm glad you are ok. Not sure what is the best approach for this issue, but if you want me to help you test any of those 2 solutions, I'm here. Thanks!