def babel2datepicker(pattern):
    """Convert date format from babel (http://babel.pocoo.org/docs/dates/#date-
    fields)) to a format understood by bootstrap-datepicker."""
    if not isinstance(pattern, DateTimePattern):
        pattern = parse_pattern(pattern)

    map_fmt = {
        # days
        "d": "dd",
        "dd": "dd",
        "EEE": "D",
        "EEEE": "DD",
        "EEEEE": "D",  # narrow name => short name
        # months
        "M": "mm",
        "MM": "mm",
        "MMM": "M",
        "MMMM": "MM",
        # years
        "y": "yyyy",
        "yy": "yyyy",
        "yyy": "yyyy",
        "yyyy": "yyyy",
        # time picker format
        # hours
        "h": "%I",
        "hh": "%I",
        "H": "%H",
        "HH": "%H",
        # minutes,
        "m": "%M",
        "mm": "%M",
        # seconds
        "s": "%S",
        "ss": "%S",
        # am/pm
        "a": "%p",
    }

    return pattern.format % map_fmt
def babel2datepicker ( pattern ) : if not isinstance ( pattern , DateTimePattern ) : pattern = parse_pattern ( pattern ) map_fmt = { "d" : "dd" , "dd" : "dd" , "EEE" : "D" , "EEEE" : "DD" , "EEEEE" : "D" , "M" : "mm" , "MM" : "mm" , "MMM" : "M" , "MMMM" : "MM" , "y" : "yyyy" , "yy" : "yyyy" , "yyy" : "yyyy" , "yyyy" : "yyyy" , "h" : "%I" , "hh" : "%I" , "H" : "%H" , "HH" : "%H" , "m" : "%M" , "mm" : "%M" , "s" : "%S" , "ss" : "%S" , "a" : "%p" , } return pattern . format % map_fmt
Convert date format from babel (http://babel.pocoo.org/docs/dates/#date-
    fields)) to a format understood by bootstrap-datepicker.