# lab04.py # YOUR NAME(S) AND NETID(S) HERE # DATE COMPLETED HERE """Time format functions for lab 04. There are all OPTIONAL. They are provided for additional practice. The consultants will help you with thes functions. However, they are not required to get credit for the lab.""" def standard_to_military_time(s): """ Returns: the time in 24-hour (military) format. 24-hour format has the form ':'. The hours are between 0 and 23, and are always two digits (so there must be a leading zero). The minutes are between 0 and 59, and are always 2 digits. Examples: '2:45 PM' becomes '14:45' '9:05 AM' becomes '09:05' '12:00 AM' becomes '00:00' Precondition: s a time in 12-hour (standard) format.""" # IMPLEMENT ME pass def military_to_standard_time(s): """ Returns: the time in 12-hour (standard) format. 12-hour format has the form ': AM' or ': PM'. There is space before the AM or PM. The hours must be between 1 and 12, and there is NO leading zero (so it may either be 1 or 2 digits). The minutes are between 0 and 59, and are always 2 digits. Examples: '14:45' becomes '2:45 PM' '09:05' becomes '9:45 AM' '00:00' becomes '12:00 AM' Precondition: s a time in the 24-hour (military) format.""" # IMPLEMENT ME pass def military_time_to_minutes(s): """Returns: the number of minutes since midnight The value returned is an integer Examples: '14:45' becomes 14*60+45 = 885 '09:05' becomes 9*50+5 = 545 '00:00' becomes 0 Precondition: s a time in 24-hour (military) format.""" # IMPLEMENT ME pass def standard_time_to_minutes(s): """Returns: the number of minutes since midnight The value returned is an integer Examples: '2:45 PM' becomes 14*60+45 = 885 '9:05 AM' becomes 9*50+5 = 545 '12:00 AM' becomes 0 Precondition: s a time in 12-hour (standard) format.""" # HINT: If you implemented all of the functions above # you can use them as helpers pass def military_to_verbose_time(s): """ Returns: the time in verbose format. Verbose format has the form ' hour(s) and minutes' where h is between 0 and 23, and m is between 0 and 59. Because there is no 'AM' or 'PM', the result is the same as military time, but with English words attached. The values h and m may be either one or two digits; there is no leading zeroes. The words must be grammatically correct. So a value of 1 is singular, while any other value (including 0) must be plural. Examples: '14:45' becomes '14 hours and 45 minutes' '09:01' becomes '9 hours and 1 minute' '01:25' becomes '1 hour and 25 minutes' '00:00' becomes '0 hours and 0 minutes' Precondition: s a time in 24-hour (military) format.""" # IMPLEMENT ME pass def verbose_to_military_time(s): """ Returns: the time in 24-hour (military) format. 24-hour format has the form ':'. The hours are between 0 and 23, and are always two digits (so there must be a leading zero). The minutes are between 0 and 59, and are always 2 digits. Examples: '14 hours and 45 minutes' becomes '14:45' '9 hours and 1 minute' becomes '09:01' '1 hour and 25 minutes' becomes '01:25' '0 hours and 0 minutes' becomes '00:00' Precondition: s a time in verbose format.""" # IMPLEMENT ME pass def standard_to_verbose_time(s): """ Returns: the time in verbose format. Verbose format has the form ' hour(s) and minutes' where h is between 0 and 23, and m is between 0 and 59. Because there is no 'AM' or 'PM', the result is the same as military time, but with English words attached. The values h and m may be either one or two digits; there is no leading zeroes. The words must be grammatically correct. So a value of 1 is singular, while any other value (including 0) must be plural. Examples: '2:45 PM' becomes '14 hours and 45 minutes' '9:01 AM' becomes '9 hours and 1 minute' '1:25 AM' becomes '1 hour and 25 minutes' '12:00 AM' becomes '0 hours and 0 minutes' Precondition: s a time in the 12-hour (standard) format.""" # HINT: If you implemented all of the functions above # you can use them as helpers pass def verbose_to_standard_time(s): """ Returns: the time in 24-hour (military) format. 12-hour format has the form ': AM' or ': PM'. There is space before the AM or PM. The hours must be between 1 and 12, and there is NO leading zero (so it may either be 1 or 2 digits). The minutes are between 0 and 59, and are always 2 digits. Examples: '14 hours and 45 minutes' becomes '2:45 PM' '9 hours and 1 minute' becomes '9:01 AM' '1 hour and 25 minutes' becomes '1:25 AM' '0 hours and 0 minutes' becomes '12:00 AM' Precondition: s a time in verbose format.""" # HINT: If you implemented all of the functions above # you can use them as helpers pass