I make a function node but code inside no have an error but on flow show my function have error how can i fix this and this can run also no error
Edit: i can use this fine in v.0.19 before upgrade to v.0.20 i got this
[{"id":"23fd1334.5bda84","type":"function","z":"da0b685e.90fc9","name":"","func":"function formatDate(date) {\n var d = new Date(date),\n month = '' + (d.getMonth() + 1),\n day = '' + d.getDate(),\n year = d.getFullYear();\n\n if (month.length < 2) month = '0' + month;\n if (day.length < 2) day = '0' + day;\n\n return [year, month, day].join('');\n}\n\n\nfunction hex_to_ascii(str1)\n {\n\tvar hex = str1.toString();\n\tvar str = '';\n\tfor (var n = 0; n < hex.length; n += 2) {\n\t\tstr += String.fromCharCode(parseInt(hex.substr(n, 2), 16));\n\t}\n\treturn str;\n }\n\n\nvar date;\ndate = new Date();\ndate = (date.getFullYear() + ('00' + (date.getMonth() + 1)).slice(-2) + ('00' + date.getDate()).slice(-2) + ('00' + date.getHours()).slice(-2) + ('00' + date.getMinutes()).slice(-2) + ('00' + date.getSeconds()).slice(-2));\n\n\nvar message = msg.payload;\nvar newMsg = flow.get('udp');\nvar ss = Buffer.from(newMsg.rx.userdata.payload, 'base64').toString('ascii');\n\nvar volume = hex_to_ascii(ss);\n\n// if (volume == \"30303030\"){\n \n// volume = \"0\";\n// } else if (volume == \"30303031\"){\n \n// volume = \"1\";\n// } else if (volume == \"30303032\"){\n \n// volume = \"2\";\n// } else if (volume == \"30303033\"){\n \n// volume = \"3\";\n// }\n\nvar rssi = newMsg.rx.gwrx[0].rssi;\nvar time = message[0].time;\nvar times = message[0].time.split(':');\nvar time_plus = (parseInt(times[0]) + 01).toString().concat(times[1]).concat(times[2]);\n\nvar imei = message[0].imei;\n\nvar dates = parseInt(formatDate(message[0].date));\nvar year = dates.toString().substr(0,4);\nvar month = dates.toString().substr(4, 2);\nvar day = dates.toString().substr(6, 2);\nvar newyear = (parseInt(year) + 1).concat(\"01\").concat(\"01\");\nvar dates_plus = dates + 1;\nvar day_plus = dates.toString().substr(0,4).concat(\"0\").concat(parseInt(dates.toString().substr(4,2)) + 01).concat(\"01\");\n\n\n \nif (month == '01' || month == '03' || month == '05' || month == '07' || month == '08' || month == '10' || month == '12') {\n\n if (day == '31' && time == '23:00:00') {\n\n node.send({\n topic: \"INSERT INTO `electro_count`(`tstamp_volume`, `tstamp_pressure`, `imei`, `date`, `time`, `timezone_code`, `lit_perpulse`, `pulse_for`, `pulse_re`, `pressure`, `event_setup`, `byte_check`) VALUES ('\" + date + \"','\" + date + \"','\" + imei + \"','\" + day_plus + \"','\" + \"000000\" + \"','\" + \"Time Zone 6\" + \"','\" + \"10\" + \"','\" + volume + \"','\" + \"0\" + \"','\" + \"0\" + \"','\" + \"N\" + \"','\" + \"ff\" + \"')\"\n });\n\n } else if (day == '31' && time == '23:00:00' && month == '12'){\n \n node.send({\n topic: \"INSERT INTO `electro_count`(`tstamp_volume`, `tstamp_pressure`, `imei`, `date`, `time`, `timezone_code`, `lit_perpulse`, `pulse_for`, `pulse_re`, `pressure`, `event_setup`, `byte_check`) VALUES ('\" + date + \"','\" + date + \"','\" + imei + \"','\" + newyear + \"','\" + \"000000\" + \"','\" + \"Time Zone 6\" + \"','\" + \"10\" + \"','\" + volume + \"','\" + \"0\" + \"','\" + \"0\" + \"','\" + \"N\" + \"','\" + \"ff\" + \"')\"\n });\n \n } else {\n\n if (time == '01:00:00' || time == '02:00:00' || time == '03:00:00') {\n\n node.send({\n topic: \"INSERT INTO `electro_count`(`tstamp_volume`, `tstamp_pressure`, `imei`, `date`, `time`, `timezone_code`, `lit_perpulse`, `pulse_for`, `pulse_re`, `pressure`, `event_setup`, `byte_check`) VALUES ('\" + date + \"','\" + date + \"','\" + imei + \"','\" + dates + \"','\" + time_plus + \"','\" + \"Time Zone 1\" + \"','\" + \"10\" + \"','\" + volume + \"','\" + \"0\" + \"','\" + \"0\" + \"','\" + \"N\" + \"','\" + \"ff\" + \"')\"\n });\n } else if (time == '05:00:00' || time == '06:00:00' || time == '07:00:00' || time == '04:00:00') {\n \n node.send({\n topic: \"INSERT INTO `electro_count`(`tstamp_volume`, `tstamp_pressure`, `imei`, `date`, `time`, `timezone_code`, `lit_perpulse`, `pulse_for`, `pulse_re`, `pressure`, `event_setup`, `byte_check`) VALUES ('\" + date + \"','\" + date + \"','\" + imei + \"','\" + dates + \"','\" + time_plus + \"','\" + \"Time Zone 2\" + \"','\" + \"10\" + \"','\" + volume + \"','\" + \"0\" + \"','\" + \"0\" + \"','\" + \"N\" + \"','\" + \"ff\" + \"')\"\n });\n } else if (time == '09:00:00' || time == '10:00:00' || time == '11:00:00' || time == '08:00:00') {\n \n node.send({\n topic: \"INSERT INTO `electro_count`(`tstamp_volume`, `tstamp_pressure`, `imei`, `date`, `time`, `timezone_code`, `lit_perpulse`, `pulse_for`, `pulse_re`, `pressure`, `event_setup`, `byte_check`) VALUES ('\" + date + \"','\" + date + \"','\" + imei + \"','\" + dates + \"','\" + time_plus + \"','\" + \"Time Zone 3\" + \"','\" + \"10\" + \"','\" + volume + \"','\" + \"0\" + \"','\" + \"0\" + \"','\" + \"N\" + \"','\" + \"ff\" + \"')\"\n });\n } else if (time == '13:00:00' || time == '14:00:00' || time == '15:00:00' || time == '12:00:00') {\n \n node.send({\n topic: \"INSERT INTO `electro_count`(`tstamp_volume`, `tstamp_pressure`, `imei`, `date`, `time`, `timezone_code`, `lit_perpulse`, `pulse_for`, `pulse_re`, `pressure`, `event_setup`, `byte_check`) VALUES ('\" + date + \"','\" + date + \"','\" + imei + \"','\" + dates + \"','\" + time_plus + \"','\" + \"Time Zone 4\" + \"','\" + \"10\" + \"','\" + volume + \"','\" + \"0\" + \"','\" + \"0\" + \"','\" + \"N\" + \"','\" + \"ff\" + \"')\"\n });\n } else if (time == '17:00:00' || time == '18:00:00' || time == '19:00:00' || time == '16:00:00') {\n \n node.send({\n topic: \"INSERT INTO `electro_count`(`tstamp_volume`, `tstamp_pressure`, `imei`, `date`, `time`, `timezone_code`, `lit_perpulse`, `pulse_for`, `pulse_re`, `pressure`, `event_setup`, `byte_check`) VALUES ('\" + date + \"','\" + date + \"','\" + imei + \"','\" + dates + \"','\" + time_plus + \"','\" + \"Time Zone 5\" + \"','\" + \"10\" + \"','\" + volume + \"','\" + \"0\" + \"','\" + \"0\" + \"','\" + \"N\" + \"','\" + \"ff\" + \"')\"\n });\n } else if (time == '21:00:00' || time == '22:00:00' || time == '20:00:00') {\n \n node.send({\n topic: \"INSERT INTO `electro_count`(`tstamp_volume`, `tstamp_pressure`, `imei`, `date`, `time`, `timezone_code`, `lit_perpulse`, `pulse_for`, `pulse_re`, `pressure`, `event_setup`, `byte_check`) VALUES ('\" + date + \"','\" + date + \"','\" + imei + \"','\" + dates + \"','\" + time_plus + \"','\" + \"Time Zone 6\" + \"','\" + \"10\" + \"','\" + volume + \"','\" + \"0\" + \"','\" + \"0\" + \"','\" + \"N\" + \"','\" + \"ff\" + \"')\"\n });\n } else if (time == '23:00:00') {\n node.send({\n topic: \"INSERT INTO `electro_count`(`tstamp_volume`, `tstamp_pressure`, `imei`, `date`, `time`, `timezone_code`, `lit_perpulse`, `pulse_for`, `pulse_re`, `pressure`, `event_setup`, `byte_check`) VALUES ('\" + date + \"','\" + date + \"','\" + imei + \"','\" + dates + \"','\" + \"000000\" + \"','\" + \"Time Zone 6\" + \"','\" + \"10\" + \"','\" + volume + \"','\" + \"0\" + \"','\" + \"0\" + \"','\" + \"N\" + \"','\" + \"ff\" + \"')\"\n });\n } else if (time == '00:00:00') {\n \n node.send({\n topic: \"INSERT INTO `electro_count`(`tstamp_volume`, `tstamp_pressure`, `imei`, `date`, `time`, `timezone_code`, `lit_perpulse`, `pulse_for`, `pulse_re`, `pressure`, `event_setup`, `byte_check`) VALUES ('\" + date + \"','\" + date + \"','\" + imei + \"','\" + dates_plus + \"','\" + time_plus + \"','\" + \"Time Zone 1\" + \"','\" + \"10\" + \"','\" + volume + \"','\" + \"0\" + \"','\" + \"0\" + \"','\" + \"N\" + \"','\" + \"ff\" + \"')\"\n });\n \n } \n\n }\n \n\n}\n\nif (month == '04' || month == '06' || month == '09' || month == '11') {\n\n if (day == '30' && time == '23:00:00') {\n\n node.send({\n topic: \"INSERT INTO `electro_count`(`tstamp_volume`, `tstamp_pressure`, `imei`, `date`, `time`, `timezone_code`, `lit_perpulse`, `pulse_for`, `pulse_re`, `pressure`, `event_setup`, `byte_check`) VALUES ('\" + date + \"','\" + date + \"','\" + imei + \"','\" + day_plus+ \"','\" + \"000000\" + \"','\" + \"Time Zone 6\" + \"','\" + \"10\" + \"','\" + volume + \"','\" + \"0\" + \"','\" + \"0\" + \"','\" + \"N\" + \"','\" + \"ff\" + \"')\"\n });\n\n } else {\n\n if (time == '01:00:00' || time == '02:00:00' || time == '03:00:00') {\n\n node.send({\n topic: \"INSERT INTO `electro_count`(`tstamp_volume`, `tstamp_pressure`, `imei`, `date`, `time`, `timezone_code`, `lit_perpulse`, `pulse_for`, `pulse_re`, `pressure`, `event_setup`, `byte_check`) VALUES ('\" + date + \"','\" + date + \"','\" + imei + \"','\" + dates + \"','\" + time_plus + \"','\" + \"Time Zone 1\" + \"','\" + \"10\" + \"','\" + volume + \"','\" + \"0\" + \"','\" + \"0\" + \"','\" + \"N\" + \"','\" + \"ff\" + \"')\"\n });\n } else if (time == '05:00:00' || time == '06:00:00' || time == '07:00:00' || time == '04:00:00') {\n \n node.send({\n topic: \"INSERT INTO `electro_count`(`tstamp_volume`, `tstamp_pressure`, `imei`, `date`, `time`, `timezone_code`, `lit_perpulse`, `pulse_for`, `pulse_re`, `pressure`, `event_setup`, `byte_check`) VALUES ('\" + date + \"','\" + date + \"','\" + imei + \"','\" + dates + \"','\" + time_plus + \"','\" + \"Time Zone 2\" + \"','\" + \"10\" + \"','\" + volume + \"','\" + \"0\" + \"','\" + \"0\" + \"','\" + \"N\" + \"','\" + \"ff\" + \"')\"\n });\n } else if (time == '09:00:00' || time == '10:00:00' || time == '11:00:00' || time == '08:00:00') {\n \n node.send({\n topic: \"INSERT INTO `electro_count`(`tstamp_volume`, `tstamp_pressure`, `imei`, `date`, `time`, `timezone_code`, `lit_perpulse`, `pulse_for`, `pulse_re`, `pressure`, `event_setup`, `byte_check`) VALUES ('\" + date + \"','\" + date + \"','\" + imei + \"','\" + dates + \"','\" + time_plus + \"','\" + \"Time Zone 3\" + \"','\" + \"10\" + \"','\" + volume + \"','\" + \"0\" + \"','\" + \"0\" + \"','\" + \"N\" + \"','\" + \"ff\" + \"')\"\n });\n } else if (time == '13:00:00' || time == '14:00:00' || time == '15:00:00' || time == '12:00:00') {\n \n node.send({\n topic: \"INSERT INTO `electro_count`(`tstamp_volume`, `tstamp_pressure`, `imei`, `date`, `time`, `timezone_code`, `lit_perpulse`, `pulse_for`, `pulse_re`, `pressure`, `event_setup`, `byte_check`) VALUES ('\" + date + \"','\" + date + \"','\" + imei + \"','\" + dates + \"','\" + time_plus + \"','\" + \"Time Zone 4\" + \"','\" + \"10\" + \"','\" + volume + \"','\" + \"0\" + \"','\" + \"0\" + \"','\" + \"N\" + \"','\" + \"ff\" + \"')\"\n });\n } else if (time == '17:00:00' || time == '18:00:00' || time == '19:00:00' || time == '16:00:00') {\n \n node.send({\n topic: \"INSERT INTO `electro_count`(`tstamp_volume`, `tstamp_pressure`, `imei`, `date`, `time`, `timezone_code`, `lit_perpulse`, `pulse_for`, `pulse_re`, `pressure`, `event_setup`, `byte_check`) VALUES ('\" + date + \"','\" + date + \"','\" + imei + \"','\" + dates + \"','\" + time_plus + \"','\" + \"Time Zone 5\" + \"','\" + \"10\" + \"','\" + volume + \"','\" + \"0\" + \"','\" + \"0\" + \"','\" + \"N\" + \"','\" + \"ff\" + \"')\"\n });\n } else if (time == '21:00:00' || time == '22:00:00' || time == '20:00:00') {\n \n node.send({\n topic: \"INSERT INTO `electro_count`(`tstamp_volume`, `tstamp_pressure`, `imei`, `date`, `time`, `timezone_code`, `lit_perpulse`, `pulse_for`, `pulse_re`, `pressure`, `event_setup`, `byte_check`) VALUES ('\" + date + \"','\" + date + \"','\" + imei + \"','\" + dates + \"','\" + time_plus + \"','\" + \"Time Zone 6\" + \"','\" + \"10\" + \"','\" + volume + \"','\" + \"0\" + \"','\" + \"0\" + \"','\" + \"N\" + \"','\" + \"ff\" + \"')\"\n });\n } else if (time == '23:00:00') {\n node.send({\n topic: \"INSERT INTO `electro_count`(`tstamp_volume`, `tstamp_pressure`, `imei`, `date`, `time`, `timezone_code`, `lit_perpulse`, `pulse_for`, `pulse_re`, `pressure`, `event_setup`, `byte_check`) VALUES ('\" + date + \"','\" + date + \"','\" + imei + \"','\" + dates + \"','\" + \"000000\" + \"','\" + \"Time Zone 6\" + \"','\" + \"10\" + \"','\" + volume + \"','\" + \"0\" + \"','\" + \"0\" + \"','\" + \"N\" + \"','\" + \"ff\" + \"')\"\n });\n } else if (time == '00:00:00') {\n \n node.send({\n topic: \"INSERT INTO `electro_count`(`tstamp_volume`, `tstamp_pressure`, `imei`, `date`, `time`, `timezone_code`, `lit_perpulse`, `pulse_for`, `pulse_re`, `pressure`, `event_setup`, `byte_check`) VALUES ('\" + date + \"','\" + date + \"','\" + imei + \"','\" + dates_plus + \"','\" + time_plus + \"','\" + \"Time Zone 1\" + \"','\" + \"10\" + \"','\" + volume + \"','\" + \"0\" + \"','\" + \"0\" + \"','\" + \"N\" + \"','\" + \"ff\" + \"')\"\n });\n \n } \n\n }\n} \n\n\n\n\n","outputs":1,"noerr":2,"x":410,"y":440,"wires":[[]]}]