Skip to content

You recently quit your job to start a space logistics company that uses rockets to deliver critical cargo to colonies on demand. Since you're still in the startup phase, you're handling everything yourself, including writing the software to manage complex scheduling and timing across different space colonies.

Before developing a full rocket flight planning and logistics system, you want to create core functions using Python's datetime module to handle dates, times, and durations. These basic functions are essential for your rocket delivery service. In this project, you will make simple reusable functions for working with timestamps, calculating rocket landing times based on launch and travel duration, and figuring out days until a delivery deadline to keep those customers updated!

This project is data-less, but you can test your functions by calling them in the workspace and passing them the required variables.

# Re-run this cell
from datetime import datetime, timedelta
# Start coding here. Use as many cells as you need.
def format_date(timestamp, datetime_format):
    datetime_obj = datetime.fromtimestamp(timestamp)
    datetime_str = datetime_obj.strftime(datetime_format)
    return datetime_str

def calculate_landing_time(rocket_launch_dt, travel_duration):
    landing_date = rocket_launch_dt + timedelta(days=travel_duration)
    landing_date_str = landing_date.strftime("%d-%m-%Y")
    return landing_date_str

def days_until_delivery(expected_delivery_dt, current_dt):
    time_until_del = expected_delivery_dt - current_dt
    days_until = time_until_del.days
    return days_until