I try not to ask stupid questions and prefer to struggle until I figure it out myself. However, after many hours I am at a loss.
I'm running Node-Red version 3.0.2, Node.js version 16.20.1, Dashboard version 3.5.0 on Linux 5.10.103-v7+ arm LE. A recent upgrade changed the behavior of the Text Input node set to Time Picker mode.
According to the documentation, and how it use to work, the output payload is the number of ms since midnight. However, it is returning the number of ms since midnight offset by plus 8 hours. I have checked that the time/date on the hardware is indeed correct. I see that someone else on the forum created a topic stating that Dashboard 3.5 switched from local time to UTC (or vice-versa) but there were no responses. The delta between UTC and my local time (Pacific Daylight Savings) is 7 hours....not 8. This may be explained by the difference between UTC and Pacific Standard Time?
The simple flow below demonstrates the problem. The goal is to return the time in hh:mm format. The timeFix variable in the function node must be set to negative 8 hours (in ms) to return the correct time.
If the logic of my actual flow was simple I would make the offset change and move on. However, in my actual flow the text input node receives feedback from multiple sources and that is proving difficult to implement for all possible cases (sometimes the time is right, other times it is off by 8 hours).
Any insight would be most appreciated.
[
{
"id": "ce34a537ceac0b5e",
"type": "function",
"z": "bfc13c72.c79e1",
"name": "Calc Time",
"func": "// const fixTime = 0 // Return value is off by +8 hours\nconst fixTime = - 8 * 60 * 60 * 1000; // Returns correct time\n\nconst mSec = msg.payload + fixTime;\nnode.warn(`mSec = ${mSec}`);\nmsg.payload = parseInt(mSec / 3.6e6).toString().padStart(2, '0') + ':' + parseInt((mSec % 3.6e6) / 6e4).toString().padStart(2, '0');\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1200,
"y": 1520,
"wires": [
[
"b4c69a2b9229d1bc"
]
]
},
{
"id": "b4c69a2b9229d1bc",
"type": "debug",
"z": "bfc13c72.c79e1",
"name": "Debug Test Ctrl",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1380,
"y": 1520,
"wires": []
},
{
"id": "c46224f62d551cb9",
"type": "ui_text_input",
"z": "bfc13c72.c79e1",
"name": "Test Ctrl",
"label": "Test Ctrl",
"tooltip": "",
"group": "36a6f291.d9686e",
"order": 6,
"width": "4",
"height": "1",
"passthru": false,
"mode": "time",
"delay": "0",
"topic": "testTime",
"sendOnBlur": false,
"className": "",
"topicType": "str",
"x": 1040,
"y": 1520,
"wires": [
[
"ce34a537ceac0b5e"
]
]
},
{
"id": "36a6f291.d9686e",
"type": "ui_group",
"name": "Other",
"tab": "f5ab6e8f.f1246",
"order": 3,
"disp": true,
"width": "8",
"collapse": true
},
{
"id": "f5ab6e8f.f1246",
"type": "ui_tab",
"name": "Test",
"icon": "dashboard",
"order": 7,
"disabled": false,
"hidden": false
}
]