from typing import Union
from datetime import datetime


def optional_time(
    datetime_object: Union[datetime, None], fmt: str = "%d/%m/%Y %H:%M:%S"
) -> Union[str, None]:
    """Returns a formatted date-time string if argument is a datetime object

    :param datetime_object: datatime to be converted to string
    :param fmt: format string to be used to produce the string
    :return: formatted string or None
    """
    if datetime_object is None:
        return None
    return datetime_object.strftime(fmt)