Hi team,
I'm making a function node:
var newmsg = { payload: { results: [] } };
var duration = 0;
var numslots = 0;
var newslots = 0;
for (let i = 0; i < msg.payload.results.length; i++ ) {
duration = Date.parse(msg.payload.results[i].valid_to) - Date.parse(msg.payload.results[i].valid_from);
newslots = duration / 3600000;
for (let j = 0; j < newslots; j++ ) {
var data = { };
var valid_from_millis = parseInt(Date.parse(msg.payload.results[i].valid_from), 10) + (j * 1800000);
var validfrom = new Date(valid_from_millis);
data.valid_from = validfrom.toISOstring();
data.value_exc_vat = msg.payload.results[i].value_exc_vat;
data.value_inc_vat = msg.payload.results[i].value_inc_vat;
newmsg.payload.results.push (data);
numslots++;
}
}
newmsg.payload.count = numslots;
return newmsg;
I keep getting this error: TypeError: validfrom.toISOstring is not a function
I know this happens when you try to call .toISOstring
on something that isn't a Date
- but I think I am calling it on a Date
?
Any advice greatly appreciated.
Thank you
James