Convert a 12-Hour Time String into 24-Hour Military Format

Write a function that accepts a time string in 12-hour format (e.g., '02:30 PM', '12:00 AM') and returns its equivalent in 24-hour format ('14:30', '00:00'). Handle all edge cases: midnight (12:00 AM → 00:00), noon (12:00 PM → 12:00), invalid inputs, and optional seconds component. Implement without using the Date object for parsing (string manipulation only). Useful for scheduling UIs and calendar apps.

Examples
Input: []
Output:
Hints

Convert a 12-Hour Time String into 24-Hour Military Format

Write a function that accepts a time string in 12-hour format (e.g., '02:30 PM', '12:00 AM') and returns its equivalent in 24-hour format ('14:30', '00:00'). Handle all edge cases: midnight (12:00 AM → 00:00), noon (12:00 PM → 12:00), invalid inputs, and optional seconds component. Implement without using the Date object for parsing (string manipulation only). Useful for scheduling UIs and calendar apps.