Closed david-mcpherson closed 5 months ago
I don't think this issue is there any more in the develop branch, it has been fixed
I don't think this issue is there any more in the develop branch, it has been fixed
It's still reproducible as of 5577fba8b2787e80e4130944ebfed90e47525fec. But it is still fixed by prepending the if condition with a guard to check that period
is defined.
Sections cannot be added for 24-hour clock users.
Here's the console error:
The convertTo24HourFormat function extracts timePart and period from the given time. 12-hour times have a period like 'a.m.' or 'p.m.'. But 24-hour times have a period of
null
.The function calls period.toLowerCase(), even if the period is null.
Current code:
if (period.toLowerCase() === 'p.m.' && hours !== 12) { hours += 12; } else if (period.toLowerCase() === 'a.m.' && hours === 12) { hours = 0; }
Proposed fix:
if (period && period.toLowerCase() === 'p.m.' && hours !== 12) { hours += 12; } else if (period && period.toLowerCase() === 'a.m.' && hours === 12) { hours = 0; }