Text Input Time Picker Returns Incorrect ms From Midnight

You are getting your alpines mixed up with your Debians. It's apk not apt (re-read that linked doc :joy:)

I tried apk add tzdata but received the following error. I'm less fluent with Linux than I am JS (need to have a cheat sheet nearby although I love the command line). I am a complete novice with Docker containers. I spent a couple of days and after much trial and tribulation, was able to create a node-red container (with my flows.json file imported) talking to a mqtt container that I could access from an external computer (one of those woo-hoo moments where you want to share your accomplishment with someone but......the wife had absolute zero appreciation for :cold_sweat:) That said, I am sure, with the help of Google, I will figure it out. Mondays, work-wise, are well.......Mondays. So it will probably take me a couple of days before I can get back to this and post the results. I appreciate the suggestion!

ERROR: Unable to lock database: Permission denied
ERROR: Failed to open apk database: Pefmission denied
1 Like

That particular error and that particular command means you need to do it with sudo

Why are you using docker then?

I am not. I am running my production system on a pi. You asked me if I had any other node-red systems to test on. I was messing around with Docker containers as learning exercise and because I'd like to eventually move my system off a pi to something more powerful. But I have not done that yet precisely because I do not have sufficient experience. Baby steps:)

That particular error and that particular command means you need to do it with sudo

Yes....that was my first thought but it returns:

sudo: command not found

Anyhow, I can figure that part out, not a big deal. It just is not going to happen on a Monday.

That is another nod to what @colin said :-

Apline images don't ship with sudo: linux - Use sudo inside Dockerfile (Alpine) - Stack Overflow

I understand my ignorance with Docker images complicates the main issue. That was not my intent and why I am NOT seeking help with that. I am confident I can figure it out. In terms of why Docker: I was playing around with it to expand my knowledge and because there are other containers, that require Linux, I would like to run on an Intel Nuc I have on hand. My first Docker container attempt (as a learning experience) was to get node-red and MQTT up and running. So when Colin asked if I had another system running node-red, I said to myself, self....yes I do in the form of a Docker container. Could I install node-red directly onto a Windows 10 or 11 machine? Yes, but that will take as long as it will to figure out how to change the time zone in a Docker container (it can't be that hard).

1 Like

RESULTS

Executive Summary

Upgrading the node-red dashboard from 3.2.3 to 3.5 causes the problem. Specifically, the number of ms since midnight for a Text Input set to Time mode is offset by 8 hours worth of ms when your time zone is set to PDT (US - Pacific Daylight Time)

Detail-1 (Dashboard Version 3.2.3 Works As Expected)

I was able to change the timezone in the node-red docker container. I simply had to attach a terminal as root before I could install tzdata (the default user is "node-red"). As mentioned above sudo is also not installed by the image. My simple test flow (included below, consists of - Text Input node to Function node to Debug node) produces the CORRECT result (i.e., the correct number of ms since midnight local time) using node-red dashboard v 3.2.3. The following is the output for a Text Input node set to Time mode with an input of 02:00 AM:

Results for Detail-1

8/29/2023, 7:52:08 PMnode: Calc Time
function : (warn)
"mSec = 7200000"
8/29/2023, 7:52:08 PMnode: Calc Time
function : (warn)
"02:00"
8/29/2023, 7:52:09 PMnode: debug 30
msg.payload : string[5]
"02:00"

Detail-2 (Text Input Node Produces Incorrect Result After Update to Dashboard t v3.5)

I then upgraded the dashboard to 3.5 (via Manage Palette), restarted the container, and checked via the date command my current time zone was still PDT (which was true). The following is the output from the same test flow with the same input of 2:00 AM. It returns 10:00 AM and is therefore offset by positive 8 hours:

8/29/2023, 8:10:23 PMnode: Calc Time
function : (warn)
"mSec = 36000000"
8/29/2023, 8:10:23 PMnode: Calc Time
function : (warn)
"10:00"
8/29/2023, 8:10:23 PMnode: debug 30
msg.payload : string[5]
"10:00"

Conclusion

I believe this proves there is a bug with the update as it is reproducible on both a Pi and a Docker container running under WSL2 on a Windows machine. I understand the dashboard code is deprecated. Therefore, I will adjust my flow to avoid using the Text Input node set to Time mode. I greatly appreciate everyone's input and I am not just saying that. Donating your free time to help us "technology challenged users" is very generous!!!

Test Flow Used for Both Cases (Detail-1 and Detail-2)

[
    {
        "id": "a6847b2886a8226d",
        "type": "ui_text_input",
        "z": "bfc13c72.c79e1",
        "name": "",
        "label": "",
        "tooltip": "",
        "group": "e42c6421.b8b248",
        "order": 7,
        "width": 0,
        "height": 0,
        "passthru": false,
        "mode": "time",
        "delay": "0",
        "topic": "topic",
        "sendOnBlur": false,
        "className": "",
        "topicType": "msg",
        "x": 160,
        "y": 1620,
        "wires": [
            [
                "ce34a537ceac0b5e"
            ]
        ]
    },
    {
        "id": "ce34a537ceac0b5e",
        "type": "function",
        "z": "bfc13c72.c79e1",
        "name": "Calc Time",
        "func": "const mSec = msg.payload;\nnode.warn(`mSec = ${mSec}`);\nmsg.payload = parseInt(mSec / 3.6e6).toString().padStart(2, '0') + ':' + parseInt((mSec % 3.6e6) / 6e4).toString().padStart(2, '0');\nnode.warn(msg.payload);\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 340,
        "y": 1620,
        "wires": [
            [
                "5c9c0ad24b8d8516"
            ]
        ]
    },
    {
        "id": "5c9c0ad24b8d8516",
        "type": "debug",
        "z": "bfc13c72.c79e1",
        "name": "debug 30",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 520,
        "y": 1620,
        "wires": []
    },
    {
        "id": "e42c6421.b8b248",
        "type": "ui_group",
        "name": "Lights",
        "tab": "a7366c5.92e209",
        "order": 1,
        "disp": true,
        "width": "8",
        "collapse": true,
        "className": ""
    },
    {
        "id": "a7366c5.92e209",
        "type": "ui_tab",
        "name": "Main 1",
        "icon": "dashboard",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]
2 Likes

Excellent digging and diagnosis. While the dashboard is not deprecated it is definitely on life support, but bug fixes (or regressions) like this can certainly be undone. I will try to find time to do that in the next few days.

2 Likes

Thank you @dceejay! I figure if people such as yourself are willing to dedicate so much of your time the least I can do as a user asking a question is to be willing put forth effort myself. Also, I tend to learn more when I struggle to solve a problem so it is a worthwhile endeavor. I really appreciate your dashboard. Great work!

Do you know the cause of the problem Dave?

[Edit] In particular what it is that is special about PDT.

How is it with the new version of the dashboard, 3.6.0?

@Colin . Apologies for the late reply. I was on a business trip and just returned. Good news.....IT VERKS perfectly! I appreciate your help. It amazes me that, more often than not, open source software is of higher quality and better supported then paid software! If you ever need help with a chemical engineering problem, I realize that is probably unlikely but none-the-less, I owe you. Thanks again....Mike.

2 Likes

I do not want to leave anyone out.....thank you @dceejay. The above message applies to you too.

Quite right, the fix was down to Dave.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.