node-red-contrib-moment
Version:
Node-Red Node that produces formatted Date/Time output using the Moment.JS library. Timezone, dst and locale aware.
218 lines • 7.93 kB
JSON
[
{
"id": "e75759f3.14aed8",
"type": "moment",
"z": "533475c4.a28eac",
"name": "",
"topic": "OBJECT OUTPUT",
"input": "",
"inputType": "msg",
"inTz": "Europe/London",
"adjAmount": 0,
"adjType": "days",
"adjDir": "add",
"format": "object",
"locale": "en_GB",
"output": "",
"outputType": "msg",
"outTz": "Europe/London",
"x": 470,
"y": 360,
"wires": [
[
"3514268f.2b575a"
]
]
},
{
"id": "749a67b1.8511e8",
"type": "inject",
"z": "533475c4.a28eac",
"name": "",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "",
"once": false,
"x": 120,
"y": 360,
"wires": [
[
"e75759f3.14aed8",
"d057c5dc.43ec08",
"6a30d321.63b5ec",
"3562ef2d.e961c",
"2046d084.fb1e4"
]
]
},
{
"id": "3514268f.2b575a",
"type": "debug",
"z": "533475c4.a28eac",
"name": "",
"active": true,
"console": "false",
"complete": "payload",
"x": 870,
"y": 440,
"wires": []
},
{
"id": "d057c5dc.43ec08",
"type": "moment",
"z": "533475c4.a28eac",
"name": "",
"topic": "JSDATE (date) OUTPUT",
"input": "",
"inputType": "msg",
"inTz": "Europe/London",
"adjAmount": 0,
"adjType": "days",
"adjDir": "add",
"format": "jsdate",
"locale": "en_GB",
"output": "",
"outputType": "msg",
"outTz": "Europe/London",
"x": 490,
"y": 400,
"wires": [
[
"3514268f.2b575a"
]
]
},
{
"id": "6a30d321.63b5ec",
"type": "moment",
"z": "533475c4.a28eac",
"name": "",
"topic": "CALENDAR (AROUNDNOW) OUTPUT",
"input": "",
"inputType": "msg",
"inTz": "Europe/London",
"adjAmount": 0,
"adjType": "days",
"adjDir": "add",
"format": "calendar",
"locale": "en_GB",
"output": "",
"outputType": "msg",
"outTz": "Europe/London",
"x": 540,
"y": 440,
"wires": [
[
"3514268f.2b575a"
]
]
},
{
"id": "3562ef2d.e961c",
"type": "moment",
"z": "533475c4.a28eac",
"name": "",
"topic": "FROMNOW (TIMEAGO) OUTPUT",
"input": "",
"inputType": "msg",
"inTz": "Europe/London",
"adjAmount": 0,
"adjType": "days",
"adjDir": "add",
"format": "fromnow",
"locale": "en_GB",
"output": "",
"outputType": "msg",
"outTz": "Europe/London",
"x": 520,
"y": 480,
"wires": [
[
"3514268f.2b575a"
]
]
},
{
"id": "2046d084.fb1e4",
"type": "moment",
"z": "533475c4.a28eac",
"name": "",
"topic": "ISO8601 (ISO) OUTPUT",
"input": "",
"inputType": "msg",
"inTz": "Europe/London",
"adjAmount": 0,
"adjType": "days",
"adjDir": "add",
"format": "iso8601",
"locale": "en_GB",
"output": "",
"outputType": "msg",
"outTz": "Europe/London",
"x": 490,
"y": 520,
"wires": [
[
"3514268f.2b575a"
]
]
},
{
"id": "487012c7.d8d1bc",
"type": "inject",
"z": "533475c4.a28eac",
"name": "string yr 1st",
"topic": "",
"payload": "2017/6/14 20:10:10.276",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"x": 130,
"y": 400,
"wires": [
[
"e75759f3.14aed8",
"d057c5dc.43ec08",
"6a30d321.63b5ec",
"3562ef2d.e961c",
"2046d084.fb1e4"
]
]
},
{
"id": "366462c6.c51dbe",
"type": "inject",
"z": "533475c4.a28eac",
"name": "string complex",
"topic": "",
"payload": "Thu Jun 15 2017 18:02:13 GMT+0100 (GMT Summer Time)",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"x": 140,
"y": 440,
"wires": [
[
"e75759f3.14aed8",
"d057c5dc.43ec08",
"6a30d321.63b5ec",
"3562ef2d.e961c",
"2046d084.fb1e4"
]
]
},
{
"id": "d384ff51.8b4d",
"type": "comment",
"z": "533475c4.a28eac",
"name": "Expected Output",
"info": "| Input | Moment | Output |\n|------------------|-----------------------------|---------------------------------------------------------------------------------------------|\n| timestamp | OBJECT OUTPUT | {\"years\":2018,\"months\":8,\"date\":23,\"hours\":17,\"minutes\":0,\"seconds\":54,\"milliseconds\":298} |\n| | JSDATE (date) OUTPUT | Sun Sep 23 2018 17:00:54 GMT+0100 (GMT Summer Time) |\n| | CALENDAR (AROUNDNOW) OUTPUT | Today at 17:00 |\n| | FROMNOW (TIMEAGO) OUTPUT | a few seconds ago |\n| | ISO8601 (ISO) OUTPUT | 2018-09-23T16:00:54.298Z |\n| String Yr 1st | OBJECT OUTPUT | {\"years\":2017,\"months\":5,\"date\":14,\"hours\":20,\"minutes\":10,\"seconds\":10,\"milliseconds\":276} |\n| | JSDATE (date) OUTPUT | Wed Jun 14 2017 20:10:10 GMT+0100 (GMT Summer Time) |\n| | CALENDAR (AROUNDNOW) OUTPUT | 2017-06-14 |\n| | FROMNOW (TIMEAGO) OUTPUT | a year ago |\n| | ISO8601 (ISO) OUTPUT | 2017-06-14T19:10:10.276Z |\n| String (Complex) | OBJECT OUTPUT | {\"years\":2017,\"months\":5,\"date\":15,\"hours\":18,\"minutes\":2,\"seconds\":13,\"milliseconds\":0} |\n| | JSDATE (date) OUTPUT | Thu Jun 15 2017 18:02:13 GMT+0100 (GMT Summer Time) |\n| | CALENDAR (AROUNDNOW) OUTPUT | 2017-06-15 |\n| | FROMNOW (TIMEAGO) OUTPUT | a year ago |\n| | ISO8601 (ISO) OUTPUT | 2017-06-15T17:02:13.000Z |\n\nNeedess to say that your timestamp values will be different.",
"x": 780,
"y": 380,
"wires": []
}
]