Hi @ScruffR and @bko,
Great to hear from you both and thank you for your help,
I have implemented the script:
int minSinceMidnight = (Time.local() % 86400) / 60; // only take the time and drop the date and the drop seconds too
for (int i=1;i<7;i++) {
if ( periodStart[day][i] <= minSinceMidnight && minSinceMidnight < periodEnd[day][i] ) {
return i;
}
}
But upon testing it is returning a result of 55, I’m not certain why? Any ideas? I thought the maximum it would give would be 6, given the for loop - but I may be wrong.
The two arrays I am checking for the validation are:
int periodStart[5][6] = {
{'0905', '1000', '1110', '1205', '1340', '1435'} , /* initializers for row indexed by 0 | MONDAY */
{'0905', '1000', '1110', '1205', '1340', '1435'} , /* initializers for row indexed by 1 | TUESDAY */
{'0850', '0945', '1055', '1150', '1320', '0'} , /* initializers for row indexed by 3 | WEDNESDAY */
{'0905', '1000', '1110', '1205', '1340', '1435'} , /* initializers for row indexed by 4 | THURSDAY*/
{'0905', '1000', '1110', '1205', '1340', '1435'} /* initializers for row indexed by 5 | FRIDAY */
};
int periodEnd[5][6] = {
{'1000', '1055', '1205', '1300', '1435', '1530'} , /* initializers for row indexed by 0 | MONDAY */
{'1000', '1055', '1205', '1300', '1435', '1530'} , /* initializers for row indexed by 1 | TUESDAY */
{'0945', '1040', '1150', '1245', '1415', '0'} , /* initializers for row indexed by 3 | WEDNESDAY */
{'1000', '1055', '1205', '1300', '1435', '1530'} , /* initializers for row indexed by 4 | THURSDAY*/
{'1000', '1055', '1205', '1300', '1435', '1530'} /* initializers for row indexed by 5 | FRIDAY */
};
As a part of the debugging I added an else return 0 after the if statement to see what might happen and the program only gave 0 as a result.
Thank you for your help,
Sam