Open gmckeown opened 10 months ago
In the smart home display, 12 noon shows as 12am -- this should be 12 pm. The incorrect logic is in updateTimeStamp() in app.js.
A potential fix is to replace:
let suffix = 'am'; if (hours > 12) { hours -= 12; suffix = 'pm'; } else if (hours === 0) { hours = 12; }
With:
const suffix = (hours < 12) ? 'am': 'pm'; hours = hours % 12; hours = hours ? hours : 12; minutes = minutes < 10 ? '0' + minutes : minutes;
Another way to pad the minutes:
minutes = minutes.toString().padStart(2, '0');
Haven't checked whether you've got any JS version constraints or style guidelines, so apologies if any of this doesn't fit in!
Also note that an alternative to the whole function might be to use date.toLocaleTimeString with hour12 = true.
In the smart home display, 12 noon shows as 12am -- this should be 12 pm. The incorrect logic is in updateTimeStamp() in app.js.
A potential fix is to replace:
With:
Another way to pad the minutes:
Haven't checked whether you've got any JS version constraints or style guidelines, so apologies if any of this doesn't fit in!
Also note that an alternative to the whole function might be to use date.toLocaleTimeString with hour12 = true.