def datetime_format_to_js_time_format(format):
    """
    Convert a Python datetime format to a time format suitable for use with the
    JS time picker we use.
    """
    try:
        format = format.split()[1]
    except IndexError:
        pass
    converted = format
    replacements = {'%H': 'hh', '%I': 'HH', '%M': 'ii', '%S': 'ss'}
    for search, replace in replacements.items():
        converted = converted.replace(search, replace)
    return converted.strip()
