Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
382 B
2
Indexable
def format_time_slot(time_slot):
    hour, minutes, seconds = time_slot.split(':')

    hour = int(hour)

    if hour == 0:
        period = 'am'
        hour = 12
    else:
        if hour >= 1 and hour <= 11:
            period = 'am'
        else:
            period = 'pm'
            if hour > 12:
                hour = hour - 12

    return str(hour) + ':' + minutes + period