import datetime


def datetime_formatter(key, time_format='%Y/%m/%d %H:%M:%S'):
    """Create a datetime formatting function

    This factory creates a function that formats a specified key and with a
    timestamp value from a dictionary into a string.

    Parameters
    ----------

    key
        The dictionary key to format.  The corresponding value should be a
        timestamp.
    time_format
        A format string suitable for strftime().

    Returns
    -------

    format
        A factory function that takes a dictionary and returns a string.
    """

    def format(**kwargs):
        dt = datetime.datetime.fromtimestamp(kwargs[key])
        return key + ': ' + dt.strftime(time_format)

    return format