Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRobert Skoubo
6,854 PointsWhy does my code not work on the challenge for dates and times in python task 2 of 2?
Here is the code and the task that is frustrating me beyond my desire and ability to withstand. I have tried many combinations of what I thought would work. The challenging part is for making the "paris" variable to replace the 'hill_valley' value. I get the irritating "Oops" message after making a change but "Oops" does not tell me anything. Thank you.
Bob
import datetime
naive = datetime.datetime(2015, 10, 21, 4, 2)
hill_valley = naive.replace(tzinfo = datetime.timezone(datetime.timedelta(hours=-8)))
paris = hill_valley.replace(datetime.datetime(datetime.timedelta(hours = 1)))
import datetime
naive = datetime.datetime(2015, 10, 21, 4, 2)
hill_valley = naive.replace(tzinfo = datetime.timezone(datetime.timedelta(hours=-8)))
paris = hill_valley.replace(datetime.datetime(datetime.timedelta(hours = 1)))
1 Answer
Kenneth Love
Treehouse Guest TeacherYou need to move the datetime to the new timezone. You do that with .astimezone()
, not by replacing the timezone. In other words, you're answering the question "If it's 4am in Hill Valley, what time is it in Paris?"
Robert Skoubo
6,854 PointsRobert Skoubo
6,854 PointsI guess that I was trying to make some things too simple and other things too difficult. I think that I was reading into the assignment on some parts and missing some of the key elements on others. It is tough trying to assimilate and use some of these methods - I am an old fart in a young buck's world.
Thanks for your help
Bob