getTimeName function
A function to get the time name for a given hour
Implementation
String getTimeName(int hour) {
// Loop through the list and find the matching time name
for (TimeName tn in timeNames) {
if (tn.contains(hour)) {
return tn.name;
}
}
// throw error if entry value is below 0 and above 23
throw UnsupportedError("Hours range in 24 hours timing is 0 to 23"
"So make sure your entry value must be between in the given time range.");
}