{ "kind": "open-flow-workflow", "version": 1, "name": "DMY to MDY Date Converter", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_9e633643e7fa1121": { "name": "Enter day-month-year date", "kind": "start", "inputDefs": [ { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "value" } ] }, "n_d9833c0f8c5dbd83": { "inputs": { "value": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_9e633643e7fa1121", "output": "value" } ] } }, "name": "Validate and format calendar date", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "value" } ], "outputs": [ { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "data" } ], "name": "Validate and format calendar date", "moduleId": "n_88a0207a2eaa730c", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_d09575ce0c5cec70": { "name": "Month-day-year date", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "data" } ], "outputMappings": { "data": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_d9833c0f8c5dbd83", "output": "data" } ] } } } }, "edges": [ { "source": "n_9e633643e7fa1121", "target": "n_d9833c0f8c5dbd83" }, { "source": "n_d9833c0f8c5dbd83", "target": "n_d09575ce0c5cec70" } ] } }, "modules": { "n_88a0207a2eaa730c": { "name": "Validate and format calendar date", "imports": [], "source": "function convertDmyDate(value) {\n if (typeof value !== 'string' || value.length !== 10) throw new Error('Enter a date in DD/MM/YYYY format');\n const match = /^([0-9]{2})\\/([0-9]{2})\\/([0-9]{4})$/.exec(value);\n if (!match) throw new Error('Enter a date in DD/MM/YYYY format');\n const [, dayText, monthText, yearText] = match;\n const day = Number(dayText), month = Number(monthText), year = Number(yearText);\n const leap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);\n const monthDays = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\n if (month < 1 || month > 12 || day < 1 || day > monthDays[month - 1]) throw new Error('Enter a valid calendar date');\n return monthText + '/' + dayText + '/' + yearText;\n}\nexport default async function dmyDate({ value }) {\n return { data: convertDmyDate(value) };\n}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }