UDT that accepts tag paths for the inputs and does some range validation (February 30 is accepted but February 32 is not).
{
"name": "DateFromIntsUdt",
"parameters": {
"DayTagPath": {
"dataType": "String"
},
"MinuteTagPath": {
"dataType": "String"
},
"SecondTagPath": {
"dataType": "String"
},
"YearTagPath": {
"dataType": "String"
},
"HourTagPath": {
"dataType": "String"
},
"MonthTagPath": {
"dataType": "String"
}
},
"tagType": "UdtType",
"tags": [
{
"valueSource": "expr",
"expression": "if(tag({MinuteTagPath})\u003e59 || tag({MinuteTagPath}) \u003c 0,qualifiedValue(tag({MinuteTagPath}),\u0027bad\u0027,524,\u0027Minute must be between 0 and 59\u0027),tag({MinuteTagPath}))",
"name": "ValidatedMinute",
"tagType": "AtomicTag"
},
{
"valueSource": "expr",
"expression": "if(tag({YearTagPath})\u003edateExtract(now(),\u0027year\u0027)+2 || tag({YearTagPath})\u003cdateExtract(now(),\u0027year\u0027)-2,qualifiedValue(tag({YearTagPath}),\u0027bad\u0027,524,\u0027Year must be within two years of the current year\u0027),tag({YearTagPath}))",
"name": "ValidatedYear",
"tagType": "AtomicTag"
},
{
"valueSource": "expr",
"expression": "if(tag({DayTagPath})\u003e31 || tag({DayTagPath}) \u003c 1,qualifiedValue(tag({DayTagPath}),\u0027bad\u0027,524,\u0027Day must be between 1 and 31\u0027),tag({DayTagPath}))",
"name": "ValidatedDay",
"tagType": "AtomicTag"
},
{
"valueSource": "expr",
"expression": "if(tag({MonthTagPath})\u003e12 || tag({MonthTagPath}) \u003c 1,qualifiedValue(tag({MonthTagPath}),\u0027bad\u0027,524,\u0027Month must be between 1 and 12\u0027),tag({MonthTagPath}))",
"name": "ValidatedMonth",
"tagType": "AtomicTag"
},
{
"valueSource": "expr",
"expression": "getDate({[.]ValidatedYear},{[.]ValidatedMonth},{[.]ValidatedDay})",
"dataType": "DateTime",
"name": "DateOut",
"formatString": "yyyy-MM-dd h:mm:ss aa",
"tagType": "AtomicTag"
},
{
"valueSource": "expr",
"expression": "setTime({[.]DateOut},{[.]ValidatedHour},{[.]ValidatedMinute},{[.]ValidatedSecond})",
"dataType": "DateTime",
"name": "DateTimeOut",
"formatString": "yyyy-MM-dd h:mm:ss aa",
"tagType": "AtomicTag"
},
{
"valueSource": "expr",
"expression": "if(tag({HourTagPath})\u003e23 || tag({HourTagPath}) \u003c 0,qualifiedValue(tag({HourTagPath}),\u0027bad\u0027,524,\u0027Hour must be between 0 and 23\u0027),tag({HourTagPath}))",
"name": "ValidatedHour",
"tagType": "AtomicTag"
},
{
"valueSource": "expr",
"expression": "if(tag({SecondTagPath})\u003e59 || tag({SecondTagPath}) \u003c 0,qualifiedValue(tag({SecondTagPath}),\u0027bad\u0027,524,\u0027Second must be between 0 and 59\u0027),tag({SecondTagPath}))",
"name": "ValidatedSecond",
"tagType": "AtomicTag"
}
]
}