#100DaysOfCode in Python Transcripts
Chapter: Days 1-3: Playing with Datetimes
Lecture: Concepts: what did we learn

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Okay, and that was the basic overview
0:02 of datetimes.
0:04 How cool was that?
0:05 Not too bad, not too hard.
0:06 Nice way to start your #100DaysOfCode on Python, right?
0:10 Alright, so let's do a quick recap of what we covered.
0:13 There wasn't a lot so this will be pretty quick.
0:16 So we began by importing datetime and date.
0:19 And we then started to look at the differences
0:22 between datetime and date.
0:24 So a datetime object, well when we ran datetime.today(),
0:28 it included the date and the time,
0:31 so we had a timestamp in that object.
0:34 Whereas when we ran that with just date,
0:37 we only get the actual date, the calendar date.
0:40 So we the 19th of February 2018, alright.
0:44 And we found that you can't actually easily combine the two,
0:48 do maths between the two.
0:50 Okay, not without a lot of conversion.
0:55 First we gave ourselves a Christmas variable,
1:00 and we gave it its' actual date,
1:02 which is something you can do with date.
1:04 You can assign an actual date to an object.
1:08 Once we did that, we were then actually able to calculate
1:12 the amount of days between Christmas and the current date.
1:16 So that was just a bit of a little scenario
1:18 for you to use datetime and date.
1:21 Okay, next we played with timedelta.
1:27 Now we began by importing timedelta
1:29 and then we gave ourselves a timedelta object.
1:33 So we set the timedelta length as 4 days and 10 hours.
1:39 Then we discussed the fact that you can view your timedelta
1:44 in those days and you can view it in seconds,
1:49 but you can't view it in hours, okay.
1:52 And that's because it only works in days and seconds.
1:55 And the seconds only go up to a max
1:57 of the 24 hours of a day.
2:00 They expect you to do the calculations yourself.
2:04 And that's what we see here.
2:07 t.seconds / 60 / 60,
2:10 and then we get our ten hours, okay, matches up there.
2:15 As a little scenario to try, we wanted to look at the ETA.
2:20 We wanted to add the estimated time of arrival
2:23 onto the current time.
2:26 So the current time plus six is that there,
2:31 that's the object there.
2:33 That's the response there I should say, the calculation.
2:37 And we were able to add and subtract
2:39 timedelta from datetimes which is really, really cool
2:45 and makes it really easy.
2:48 And using string on that, converting it to a string,
2:51 we got a really nicely formatted timestamp here.
2:55 Very useful for log files right.
2:58 Alright, your turn.
3:02 This is where it gets a lot of fun.
3:04 What I'd like you to do for day three
3:06 is come up with something cool for you to make
3:09 with datetime or timedelta.
3:12 Think about perhaps making it a stopwatch,
3:16 maybe a timer application.
3:19 I actually think a really fun one to make
3:20 would be a Pomodoro timer.
3:22 So if you're not familiar with Pomodoro,
3:23 just go and google it.
3:25 But that would be a really cool way
3:27 of setting specific timestamps that a user could choose
3:32 using datetime and what have you.
3:34 So that would be really, really fun.
3:36 Now I know what you're thinking,
3:37 datetime is a really deep and in-depth topic,
3:41 but unfortunately we just don't have the time
3:45 to run it in this course.
3:48 So I hope you really enjoyed it.
3:50 Move onto the next video,
3:51 we are keeping it nice and simple for the first day.
3:54 Expect things to take it up a notch going forward.
3:57 So enjoy, get cracking, don't waste any time.