# Chapter11.py ## Standard Modules concept defined on page 124 ### csv, decimal in Chapter 7 ## Chapter 11 datetime for our labs ''' Standard Modules page 124 1. Standard Modules depend on the version AND release -> a module that is in 3.7 might not be in 3.12 2. You should be aware of the Module name. Standard modules COMMONLY have same names as custom modules. as keyword to import as an alias is important 3. Standard Modules are NOT updated by default pip install csv 4. You use the "import" "from import" "import as" to import into your application ''' # datetime Module page 305 ## 4 common classes that you use in datetime Module ## datetime class -> date time.millisecond ## date class -> date 12:00:00.0000 or 00:00:00.0000 ## time class -> HH:MM:SS.MMMM ONLY get time ## timedelta -> date/time calculation inv date -> 30 -> due date import datetime as dt # import MODULENAME as Alias # pages 307 and 309 formatting options for datetime # now() functions and today() functions currentDay = dt.date.today() # formatted now() print(currentDay) # type datetime currentDateTimeStamp = dt.datetime.now() print(currentDateTimeStamp) # type datetime print( type(currentDateTimeStamp) ) # print # Ask the user for their birthday bdayMonth = input("Enter the month of your birthday: ex 01-12 ") bdayDay = input("Enter you birthday day: ex (01-31) ") bdayYear = input("Enter you birthday year: ex (1990) ") birthday = bdayMonth + '/' + bdayDay + '/' + bdayYear # 12/12/1972 print(birthday) print( type(birthday) # 12/12/1972 -> string ) # Convert the input strings to store as datetime page 309 convertedDate = dt.datetime.strptime(birthday, "%m/%d/%Y") print(convertedDate) print( type(convertedDate) # datetime ) ''' Enter the month of your birthday: ex 01-12 03 Enter you birthday day: ex (01-31) 21 Enter you birthday year: ex (1990) 1990 03/21/1990 1990-03-21 00:00:00 '''