def formatter(dtformat, default=''):
    """
    Returns a function take formats a python datetime object according to the given format string
    """
    def _func(datetime_obj):
        if datetime_obj is None:
            return default
        return datetime_obj.strftime(dtformat)
    
    return _func