Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
      You have completed Python Dates and Times!
      
    
You have completed Python Dates and Times!
Preview
    
      
  In this video, we'll give you a speedy tour of the two projects you'll complete: the Birthday App and the Time Tracker. Let's get a sneak peek before diving into the details!
Resources
- Python File In/Out (14-minute workshop)
- CSV and JSON in Python (14-minute workshop)
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
                      In this course, you'll learn to
use the built-in datetime module,
                      0:00
                    
                    
                      and the third party dateutil module.
                      0:05
                    
                    
                      You'll learn to work with the building
blocks, date, time, and datetime objects.
                      0:08
                    
                    
                      We'll also talk about calculating
the difference between two dates or
                      0:14
                    
                    
                      times using both timedelta and
relativedelta.
                      0:20
                    
                    
                      Finally we'll apply all of
this knowledge practically.
                      0:23
                    
                    
                      I've got two almost completed Python
apps that are missing some key
                      0:28
                    
                    
                      functionality to do with dates and times.
                      0:33
                    
                    
                      It is your mission to complete the apps
with me using your new found knowledge.
                      0:36
                    
                    
                      Our first project is a birthdayapp.
                      0:41
                    
                    
                      It works with a CSV file that
contains all your friends birthdays.
                      0:44
                    
                    
                      When we run the app with python3
main.py it loads the data
                      0:50
                    
                    
                      from the CSV and
users get presented with this menu.
                      0:55
                    
                    
                      We can press 1 to see
the upcoming birthdays, and
                      1:00
                    
                    
                      these are the birthdays that
are coming up in the next 90 days.
                      1:03
                    
                    
                      We can enter 2 to check someone's age.
                      1:08
                    
                    
                      Let's have a look at Arby.
                      1:10
                    
                    
                      We can see Arby's birthday
down to the months and days.
                      1:13
                    
                    
                      And we can also Press 3 to
compare two people's ages.
                      1:18
                    
                    
                      Let's compare number 4 and 5.
                      1:23
                    
                    
                      And here we can see each person's age,
which one's older,
                      1:25
                    
                    
                      and then the age difference
between the two people.
                      1:30
                    
                    
                      And finally, we can quit the app.
                      1:33
                    
                    
                      Our second project is a timetracker app.
                      1:38
                    
                    
                      Again, it works with a CSV file,
and it stores data on the time
                      1:41
                    
                    
                      that we've spent working on projects for
different clients.
                      1:46
                    
                    
                      When the app is run with python3 main.py,
                      1:50
                    
                    
                      it loads data from the CSV and
presents users with a menu.
                      1:54
                    
                    
                      We can press 1 to calculate totals.
                      1:59
                    
                    
                      It will allow us to select a client,
let's do Acme, and
                      2:03
                    
                    
                      then it will give us some options.
                      2:06
                    
                    
                      We can enter a date range using 1.
                      2:09
                    
                    
                      Let's try 2023-09-01 to
2023-09-10 to see the data.
                      2:12
                    
                    
                      Or we can calculate totals,
we'll grab Acme again,
                      2:20
                    
                    
                      and we'll check the last x days.
                      2:25
                    
                    
                      And we can enter let's
say the last 5 days.
                      2:29
                    
                    
                      And we can get the data that way.
                      2:32
                    
                    
                      Or we can calculate totals for
Acme once again,
                      2:35
                    
                    
                      and Press 3 for
retrieving all data on Acme and
                      2:38
                    
                    
                      we can see every single time tracking
entry we have for that client.
                      2:42
                    
                    
                      Now we can also enter 2 to
start tracking for a client.
                      2:47
                    
                    
                      We'll select a client, let's use Emmerton.
                      2:51
                    
                    
                      And then it'll ask us for
a short description,
                      2:55
                    
                    
                      let's say sketches, and
we can press any key to return to menu.
                      2:59
                    
                    
                      Now if we come to our CSV,
we can see that this entry has
                      3:04
                    
                    
                      been added, just without an end time.
                      3:09
                    
                    
                      Then we can Press 3 to stop
tracking our current project.
                      3:13
                    
                    
                      And when we come to our CSV,
                      3:17
                    
                    
                      we can see that the end time has
been added to the latest entry.
                      3:19
                    
                    
                      Now, if we calculate totals again, and
                      3:24
                    
                    
                      have a look at Emmerton, and
we'll retrieve all data,
                      3:28
                    
                    
                      we can see that our latest
entry sketches has been added.
                      3:32
                    
                    
                      And finally,
we can Press 4 to quit the app.
                      3:38
                    
                    
                      Don't worry if you haven't learned
how to work with CSVs yet.
                      3:42
                    
                    
                      I've already completed those parts.
                      3:46
                    
                    
                      All you'll need to think about
are the functions related to dates and
                      3:49
                    
                    
                      times, which you will learn
all about in the next section.
                      3:52
                    
                    
                      But if you are interested in learning
about CSVs check the teachers notes for
                      3:56
                    
                    
                      some links.
                      4:01
                    
                    
                      Now that we know what we're aiming for,
                      4:02
                    
                    
                      let's jump into learning all
about dates and times with Python
                      4:05
                    
              
        You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up