-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdurations.py
More file actions
21 lines (16 loc) · 789 Bytes
/
durations.py
File metadata and controls
21 lines (16 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Author: Matthew Shelbourn | Student ID: 001059665 | mshelbo@wgu.edu | December, 2020
# durations.py includes various operations for calculating duration and manipulating datetime objects
from datetime import timedelta
# Calculates transit time in minutes based on the distance parameter
# Space-time complexity O(1)
def calc_dest_transit_time(distance):
truck_speed = 18
transit_hours = float(distance) / truck_speed
transit_minutes = float(transit_hours * 60)
return transit_minutes
# Calculates the delivery time of a package based on the current_time and
# transit_minutes parameters
# Space-time complexity O(1)
def calc_delivery_time(current_time, transit_minutes):
delivery_time = current_time + timedelta(minutes=transit_minutes)
return delivery_time