Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
First Commit just to get everything started
  • Loading branch information
PedroDevOps committed Dec 16, 2021
commit 780238388086b4bd2bb51fc7a715a97b52bee56b
41 changes: 41 additions & 0 deletions days/01-03-datetimes/pedroDevOps_code/datetime_date_r1d1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python3

from datetime import date
from datetime import datetime

datetime.today()
# datetime.datetime(2021, 1, 19, 14, 38, 52, 133483)

today = datetime.today()

type(today)
# <class 'datetime.datetime'>


today_date = date.today()

today_date
# datetime.date(2021, 1, 19)

type(today_date)
# <class 'datetime.date'>

today_date.month
# 1

today_date.year
# 2021

today_date.day
# 19


christmas = date(today_date.year, 12, 25)
christmas
# datetime.date(2021, 12, 25)

# We need to use != & == rather than is / is not for comparison. Sorry for the mistake in the video.
if christmas != today_date:
print("Sorry there are still " + str((christmas - today_date).days) + " days until Christmas!")
else:
print("Yay it's Christmas!")