1 00:00:00,000 --> 00:00:05,134 [MUSIC] 2 00:00:05,134 --> 00:00:06,830 Welcome to the Time Tracker app. 3 00:00:07,900 --> 00:00:10,840 Just like the last one, you're part of a larger team, and 4 00:00:10,840 --> 00:00:13,600 another developer has done most of the logic already. 5 00:00:14,820 --> 00:00:19,130 Our job is to get the date time related functions programmed. 6 00:00:19,130 --> 00:00:21,030 Let's walk through what has already been done. 7 00:00:22,620 --> 00:00:24,569 Be sure to download the project files and 8 00:00:24,569 --> 00:00:26,870 then open them up in your favorite code editor. 9 00:00:28,370 --> 00:00:32,892 Just like before, be sure to check the readme file as it will have very important 10 00:00:32,892 --> 00:00:35,110 information for you. 11 00:00:35,110 --> 00:00:37,800 Pause this video and take some time to give it a read. 12 00:00:40,250 --> 00:00:43,089 Just like before, main.py is our entry point. 13 00:00:44,210 --> 00:00:49,090 Users are prompted to make a selection and certain functions in the menus.py file 14 00:00:49,090 --> 00:00:51,790 will get run depending on the user's input. 15 00:00:53,090 --> 00:00:55,663 So let's check out the menus.py file. 16 00:00:55,663 --> 00:01:00,878 We've got a main menu that prints the main menu and deals with user choice. 17 00:01:00,878 --> 00:01:05,815 A calculate totals menu that prints a secondary menu when the user wants 18 00:01:05,815 --> 00:01:07,384 to calculate totals. 19 00:01:07,384 --> 00:01:13,550 It offers some more options and then actions depending on the user's choice. 20 00:01:13,550 --> 00:01:15,550 There is, as always, some error handling. 21 00:01:17,390 --> 00:01:21,334 If the user chooses to display all totals, the display or 22 00:01:21,334 --> 00:01:26,000 totals function of the functions.py is run directly. 23 00:01:26,000 --> 00:01:27,100 We'll check that out in a bit. 24 00:01:28,570 --> 00:01:31,808 If the user chooses to enter a date range, 25 00:01:31,808 --> 00:01:35,427 this date range menu function will be called. 26 00:01:35,427 --> 00:01:38,780 This asks user to input a date range. 27 00:01:38,780 --> 00:01:42,923 It then splits it, and then passes the client name and 28 00:01:42,923 --> 00:01:48,670 the list of date strings into display range totals, and functions.py. 29 00:01:48,670 --> 00:01:52,156 There is also some error catching as always. 30 00:01:52,156 --> 00:01:55,243 If users chose to enter the last x days, 31 00:01:55,243 --> 00:01:58,810 the last x days menu function will be called. 32 00:01:59,980 --> 00:02:06,187 The user is asked how many days they'd like to go back for, and that is passed, 33 00:02:06,187 --> 00:02:11,970 along with the client name, to display x days totals in functions.py. 34 00:02:11,970 --> 00:02:14,970 Then we've got the start tracking menu. 35 00:02:14,970 --> 00:02:18,420 If a job is already running, it stops the existing job. 36 00:02:19,650 --> 00:02:25,251 It gathers some details from the user about the client and job description, 37 00:02:25,251 --> 00:02:30,280 and passes it all to the start tracking function in functions.py. 38 00:02:30,280 --> 00:02:33,043 Finally, we have the stop tracking menu, 39 00:02:33,043 --> 00:02:36,514 which simply calls stop tracking in functions.py. 40 00:02:37,730 --> 00:02:41,803 If there isn't a job running, it'll print an error. 41 00:02:41,803 --> 00:02:46,035 A lot seems to be happening in the functions.py file. 42 00:02:46,035 --> 00:02:48,020 So let's head over there. 43 00:02:48,020 --> 00:02:51,608 Yep, definitely a lot happening here. 44 00:02:51,608 --> 00:02:54,042 And this is where we come in. 45 00:02:54,042 --> 00:02:59,930 The previous developer has once again left us some to-dos and some helpful comments. 46 00:03:01,460 --> 00:03:05,877 Before we get started, let's preemptively set up our 47 00:03:05,877 --> 00:03:09,533 virtual environment and install dateutil. 48 00:03:09,533 --> 00:03:13,466 We'll open the terminal, 49 00:03:13,466 --> 00:03:18,087 Python3- m venv myapp-env. 50 00:03:18,087 --> 00:03:26,394 And then we'll activate it with source my app-env/bin and activate. 51 00:03:26,394 --> 00:03:33,374 And of course pip install python-dateutil. 52 00:03:33,374 --> 00:03:35,290 Okay, let's get started.