def dt_format_translate(pyfmt):
    """
        Translates a Python datetime format string into an
        Excel datetime format string

        Args:
            pyfmt: the Python format string

        Returns:
            the Excel datetime format string
    """

    translate = {"%a": "ddd",
                 "%A": "dddd",
                 "%b": "mmm",
                 "%B": "mmmm",
                 "%c": "",
                 "%d": "dd",
                 "%f": "",
                 "%H": "hh",
                 "%I": "hh",
                 "%j": "",
                 "%m": "mm",
                 "%M": "mm",
                 "%p": "AM/PM",
                 "%S": "ss",
                 "%U": "",
                 "%w": "",
                 "%W": "",
                 "%x": "",
                 "%X": "",
                 "%y": "yy",
                 "%Y": "yyyy",
                 "%z": "",
                 "%Z": "",
                 }

    PERCENT = "__percent__"
    xlfmt = str(pyfmt).replace("%%", PERCENT)

    for tag, translation in translate.items():
        xlfmt = xlfmt.replace(tag, translation)

    return xlfmt.replace(PERCENT, "%")