I've got a timestamp inject node going through a date-time formatter to only output the hour of day.
I'm trying to calculate the current shift, 1st, 2nd, or 3rd based on the out of day using the array.includes() method but don't have it quite right.
// Payload is the hour of day in order to perform a shift
// calculation.
const first = [ 07, 08, 09, 10, 11, 12, 13, 14 ];
const second = [ 15, 16, 17, 18, 19, 20, 21, 22 ];
const third = [ 23, 24, 01, 02, 03, 04, 05, 06 ];
if (first.includes(msg.payload)) {
shift = 1;
}
if (second.includes(msg.payload)) {
shift = 2;
}
if (third.includes(msg.payload)) {
shift = 3;
}
return shift;
What am I doing wrong?
Thanks,
Richard