Convert datetime.timedelta to seconds
    :param value: timedelta to convert
    :type value: datetime.timedelta
    :param with_microseconds:
    :type with_microseconds: bool
    :return: seconds/seconds with microseconds or None if val is None
    :rtype: int/float/None
    :raise: TypeError when val is not timedelta

def timedelta_to_seconds(value, with_microseconds=False):
    """
    Convert datetime.timedelta to seconds
    :param value: timedelta to convert
    :type value: datetime.timedelta
    :param with_microseconds:
    :type with_microseconds: bool
    :return: seconds/seconds with microseconds or None if val is None
    :rtype: int/float/None
    :raise: TypeError when val is not timedelta
    """
    if value is None:
        return None

    if not isinstance(value, timedelta):
        raise TypeError('value must be a datetime.timedelta object')

    microseconds = value.microseconds / MICROSECONDS_IN_SECOND \
        if with_microseconds else 0

    return value.days * SECONDS_IN_DAY + value.seconds + microseconds