Please assist me with this challenge, is there an other way to solve it... do I have to go through if, elif, converting min, hours... into datetime format one by one, or is there more officiant way?
import datetime starter = datetime.datetime(2015, 10, 21, 16, 29) def delorean(int_time): new_time = datetime.datetime.fromtimestamp(int_time) return datetime.datetime.combine(starter, new_time)
Stephen Bone12,359 Points
Apologies if I'm covering something that hasn't been discussed yet as it's been a little while since I looked at this stage but assuming you've covered timedelta's you could do something like below:
import datetime starter = datetime.datetime(2015, 10, 21, 16, 29) def delorean(num): return starter + datetime.timedelta(hours=num)
Hope it helps!
Kenneth LoveTreehouse Guest Teacher
You're not going to get a timestamp as the argument to
delorean, you're going to get a number. Use that number to advance
starter by that many hours. For example, if the number is 5, return a
datetime that is
starter plus 5 hours.