feat(Date & Time Node): Overhaul of the node (#5904)
* Setup versionized node * Fix node naming * Set all possible actions * Add Current Date operation * Add timezone to current date * feat add to date operator * Change output field name to camel case * Fix info box for luxons tip * Feat subtract to date operation * Feat format date operation * Fix to node field for format date * Feat rounding operation * Feat get in between date operation * Feat add extract date operation * Add generic function for parsing date * Remove moment methods from operations * Change moment to luxon for the rest of the operations * Fix Format date operation * Fix format value * Add timezone option for current date * Add tests, improve workflow settings for testing, toString the results * Change icon for V2 * Revert "Change icon for V2" This reverts commit 46b59bea2ec6dd02a22f8d07a9736b42d751d10f. * Change workflow test name * Fix ui bug for custom format * Fix default value for format operation * Fix info box for rounding operation * Change default for units for between time operation * Inprove fields and resort time units * Fix extract week number * Resolve issue with formating and timezones * Fix field name and unit order * ⚡ restored removed test case, sync v1 with curent master * ⚡ parseDate update to support timestamps, tests * Keep same field for substract and add time * Update unit test * Improve visibility, add iso to string option * Update option naming --------- Co-authored-by: Michael Kret <michael.k@radency.com>
This commit is contained in:
@@ -0,0 +1,260 @@
|
||||
{
|
||||
"name": "node-360-quick-overhaul-of-date-and-time-node",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "21ff2e15-375d-4e68-b1ca-d48a110be238",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [-420, 20]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "addToDate",
|
||||
"magnitude": "={{ $json.currentDate }}",
|
||||
"duration": 2
|
||||
},
|
||||
"id": "b99986f1-edeb-434c-b7ed-9cc86eaec522",
|
||||
"name": "Add to date",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 2,
|
||||
"position": [140, 40]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "subtractFromDate",
|
||||
"magnitude": "={{ $json.newDate }}",
|
||||
"duration": 2
|
||||
},
|
||||
"id": "aa75a04b-0d42-46ff-87e7-75d4b4f6c7ea",
|
||||
"name": "Subtract date",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 2,
|
||||
"position": [300, 200]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "formatDate",
|
||||
"date": "={{ $json.newDate }}",
|
||||
"format": "yyyy/MM/dd"
|
||||
},
|
||||
"id": "52076d89-bc6d-4253-8ca4-9aad3a058d17",
|
||||
"name": "Format Date",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 2,
|
||||
"position": [420, 40]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "roundDate",
|
||||
"date": "={{ $json.formattedDate }}",
|
||||
"toNearest": "day"
|
||||
},
|
||||
"id": "10016499-c9da-4984-9a5f-2f8c8844fb63",
|
||||
"name": "Round Date",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 2,
|
||||
"position": [560, 200]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "getTimeBetweenDates",
|
||||
"startDate": "={{ $node['Subtract date'].json.newDate }}",
|
||||
"endDate": "={{ $node['Add to date'].json.newDate }}",
|
||||
"units": ["day"]
|
||||
},
|
||||
"id": "f62b6d0b-b13a-4fcd-b4eb-3ec7ea85e80c",
|
||||
"name": "Get between date",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 2,
|
||||
"position": [660, 40]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "extractDate",
|
||||
"date": "={{ $node.Code.json.currentDate }}",
|
||||
"part": "hour",
|
||||
"outputFieldName": "date"
|
||||
},
|
||||
"id": "764e3e08-f71b-4e42-b059-36285076fe10",
|
||||
"name": "Extract Date",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 2,
|
||||
"position": [780, 220]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"options": {
|
||||
"fromFormat": ""
|
||||
}
|
||||
},
|
||||
"id": "f0b75198-74a4-4a13-8842-340539f41d80",
|
||||
"name": "V1",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 1,
|
||||
"position": [0, -180],
|
||||
"disabled": true
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "return {\"currentDate\":\"2023-04-11T13:51:59.965+00:00\"}\n"
|
||||
},
|
||||
"id": "7ba0c2a1-a683-4975-a2ca-70904111a3fc",
|
||||
"name": "Code",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 1,
|
||||
"position": [-140, 140]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"Code": [
|
||||
{
|
||||
"json": {
|
||||
"currentDate": "2023-04-11T13:51:59.965+00:00"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Add to date": [
|
||||
{
|
||||
"json": {
|
||||
"newDate": "2023-04-13T13:51:59.965+00:00"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Subtract date": [
|
||||
{
|
||||
"json": {
|
||||
"newDate": "2023-04-11T13:51:59.965+00:00"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Format Date": [
|
||||
{
|
||||
"json": {
|
||||
"formattedDate": "2023/04/11"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Round Date": [
|
||||
{
|
||||
"json": {
|
||||
"roundedDate": "2023-04-11T00:00:00.000+00:00"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Get between date": [
|
||||
{
|
||||
"json": {
|
||||
"timeDifference": {
|
||||
"days": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"Extract Date": [
|
||||
{
|
||||
"json": {
|
||||
"date": 13
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "V1",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Code",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Add to date": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Subtract date",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Subtract date": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Format Date",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Format Date": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Round Date",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Round Date": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Get between date",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Get between date": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Extract Date",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Code": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Add to date",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"saveManualExecutions": false,
|
||||
"callerPolicy": "workflowsFromSameOwner",
|
||||
"timezone": "Etc/GMT",
|
||||
"executionTimeout": -1
|
||||
},
|
||||
"versionId": "c21daa0b-83ae-45f1-b680-d2e57423800b",
|
||||
"id": "48",
|
||||
"meta": {
|
||||
"instanceId": "8e9416f42a954d0a370d988ac3c0f916f44074a6e45189164b1a8559394a7516"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,352 @@
|
||||
{
|
||||
"name": "dateTime overhaul",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "4ef93910-a6f8-43e2-bba7-8319ef62f9ee",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [260, 820]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"values": {
|
||||
"number": [
|
||||
{
|
||||
"name": "dateMilis",
|
||||
"value": 1682918315906
|
||||
},
|
||||
{
|
||||
"name": "dateMilisFloat",
|
||||
"value": 1682918315.906
|
||||
},
|
||||
{
|
||||
"name": "dateUnix",
|
||||
"value": 1682918315
|
||||
}
|
||||
],
|
||||
"string": [
|
||||
{
|
||||
"name": "dateMilisStr",
|
||||
"value": "1682918315906"
|
||||
},
|
||||
{
|
||||
"name": "dateMilisFloatStr",
|
||||
"value": "1682918315.906"
|
||||
},
|
||||
{
|
||||
"name": "dateUnixStr",
|
||||
"value": "1682918315"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"id": "1d9bc8b7-9c8d-40c8-92f2-e94ed50d0ae5",
|
||||
"name": "Set",
|
||||
"type": "n8n-nodes-base.set",
|
||||
"typeVersion": 2,
|
||||
"position": [420, 820]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "formatDate",
|
||||
"date": "={{ $json.dateMilis }}",
|
||||
"format": "yyyy/MM/dd",
|
||||
"outputFieldName": "data",
|
||||
"additionalFields": {}
|
||||
},
|
||||
"id": "c07b9cbd-4aeb-4267-a1d3-b45ecadbd1cb",
|
||||
"name": "Date & Time6",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 2,
|
||||
"position": [680, 640]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "formatDate",
|
||||
"date": "={{ $json.dateMilisFloat }}",
|
||||
"format": "yyyy/MM/dd",
|
||||
"outputFieldName": "data",
|
||||
"additionalFields": {}
|
||||
},
|
||||
"id": "a5b7bb44-63e2-4b71-ad91-55bac329e3f6",
|
||||
"name": "Date & Time",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 2,
|
||||
"position": [680, 780]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "formatDate",
|
||||
"date": "={{ $json.dateUnix }}",
|
||||
"format": "yyyy/MM/dd",
|
||||
"outputFieldName": "data",
|
||||
"additionalFields": {}
|
||||
},
|
||||
"id": "1306d282-b5f8-4a54-8834-6207ecff65f7",
|
||||
"name": "Date & Time1",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 2,
|
||||
"position": [680, 940]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "formatDate",
|
||||
"date": "={{ $json.dateMilisStr }}",
|
||||
"format": "yyyy/MM/dd",
|
||||
"outputFieldName": "data",
|
||||
"additionalFields": {}
|
||||
},
|
||||
"id": "4823c095-1921-406e-9957-a75521bca1e5",
|
||||
"name": "Date & Time2",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 2,
|
||||
"position": [680, 1080]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "formatDate",
|
||||
"date": "={{ $json.dateMilisFloatStr }}",
|
||||
"format": "yyyy/MM/dd",
|
||||
"outputFieldName": "data",
|
||||
"additionalFields": {}
|
||||
},
|
||||
"id": "d209ac18-9935-4452-825a-42aa90daaaa5",
|
||||
"name": "Date & Time3",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 2,
|
||||
"position": [680, 1220]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "formatDate",
|
||||
"date": "={{ $json.dateUnixStr }}",
|
||||
"format": "yyyy/MM/dd",
|
||||
"outputFieldName": "data",
|
||||
"additionalFields": {}
|
||||
},
|
||||
"id": "b7065dfb-ae7e-4828-a5ea-e9c313302944",
|
||||
"name": "Date & Time4",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 2,
|
||||
"position": [680, 1380]
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "5ae1bb29-d19e-4e3d-af11-ccc53ee23bfb",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [900, 640]
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "8716cc32-d4a6-48d6-af5d-e15646006dd8",
|
||||
"name": "No Operation, do nothing1",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [900, 780]
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "88f0247d-ecc0-49a2-8bae-4e7b99ae8611",
|
||||
"name": "No Operation, do nothing2",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [900, 920]
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "99a04c1d-5426-446e-9171-2d12a5b14a13",
|
||||
"name": "No Operation, do nothing3",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [900, 1060]
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "923e317f-3e7b-4609-883d-c630034bd20c",
|
||||
"name": "No Operation, do nothing4",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [900, 1200]
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "93745a80-a2b6-414b-bcf0-938f2a2da985",
|
||||
"name": "No Operation, do nothing5",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [900, 1340]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing5": [
|
||||
{
|
||||
"json": {
|
||||
"data": "2023/05/01"
|
||||
}
|
||||
}
|
||||
],
|
||||
"No Operation, do nothing4": [
|
||||
{
|
||||
"json": {
|
||||
"data": "2023/05/01"
|
||||
}
|
||||
}
|
||||
],
|
||||
"No Operation, do nothing3": [
|
||||
{
|
||||
"json": {
|
||||
"data": "2023/05/01"
|
||||
}
|
||||
}
|
||||
],
|
||||
"No Operation, do nothing2": [
|
||||
{
|
||||
"json": {
|
||||
"data": "2023/05/01"
|
||||
}
|
||||
}
|
||||
],
|
||||
"No Operation, do nothing1": [
|
||||
{
|
||||
"json": {
|
||||
"data": "2023/05/01"
|
||||
}
|
||||
}
|
||||
],
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"data": "2023/05/01"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Set",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Set": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Date & Time6",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Date & Time",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Date & Time1",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Date & Time2",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Date & Time3",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Date & Time4",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Date & Time6": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Date & Time4": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing5",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Date & Time3": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing4",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Date & Time2": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing3",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Date & Time1": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing2",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Date & Time": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing1",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {},
|
||||
"versionId": "19282890-eff2-40ca-be11-a8fff559c964",
|
||||
"id": "21",
|
||||
"meta": {
|
||||
"instanceId": "6ebec4953fe56f1c009e7c3b107578b375137523af057073c0b5da17350651bd"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
Reference in New Issue
Block a user