import time


def time_str(arg):
    """Convert arg to time with optional format.
    Return arg, converted time if converted or None, otherwise
    """
    current = ""
    extra = "%Y", "-%m", "-%d", " %H", ":%M", ":%S", ".%f"
    for part in extra:
        current += part
        try:
            converted = time.strptime(arg, current)
            return arg, converted
        except ValueError:
            pass
    return None