Your question is Convert 24 Hours to Seconds. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
NXP Semiconductors firmware components often convert clock readings into a single elapsed-seconds value for scheduling and timestamp comparisons. Implement a function that converts either 24-hour or 12-hour time into seconds since midnight.
Define convert_to_seconds(hours, minutes, seconds, period):
period is "24H", interpret hours using 24-hour time. Valid hours are 0 through 23 for ordinary clock times. Also accept 24:00:00 and return 86400 to represent exactly one full day.period is "AM" or "PM", interpret hours using 12-hour time. Convert 12 AM to hour 0, and convert 12 PM to hour 12.def convert_to_seconds(hours, minutes, seconds, period):