Perfect! You can also calculate the time difference between two dates. Let's try it with trip dates. How long did the following trip last?
fra_mad_scheduled = datetime.date(2018, 12, 1)
mad_fra_scheduled = datetime.date(2018, 12, 7)
trip_duration = mad_fra_scheduled - fra_mad_scheduled
print('My trip lasted for', trip_duration)
My trip lasted for 6 days, 0:00:00.
By subtracting one date from another (
mad_fra_scheduled - fra_mad_scheduled), we created a
timedelta in the
timedeltas are objects that store time duration. In addition to doing other things, we can print them to the console. We'll talk more about
timedeltas later in this part.