Replace date_interval_to_seconds function with either timedelta.total_seconds() or seconds_between().