0
Cancelling a booked ticket
Can anyone please share some code of how to cancel a booking in an airline but only permitted 2hrs before the flight. Thanks
2 Answers
+ 4
from datetime import datetime
departure_time = datetime.fromisoformat('2019-06-04 18:30')
now = datetime.today()
diff_in_seconds = (departure_time - now).seconds
if departure_time < now or diff_in_seconds < 2*60*60:
# less than 2 h
print('no way')
else:
# >= 2 h
print('wellllll...')
Feel free to do the rest on your own
+ 2
Thanks for your help :)