Skip to content

Commit d0ebf11

Browse files
Update Date_Time_Timestamp.py
1 parent b46ea80 commit d0ebf11

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

Date Time Timestamp/Date_Time_Timestamp.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@
1919
# get day of the week using date.weekday() # Monday is 0
2020

2121
from datetime import date
22-
d1 = date.today()
23-
print(d1)
24-
print(d1.month, d1.day, d1.year)
25-
print(d1.weekday())
22+
todays_date = date.today()
23+
print(todays_date)
24+
print(todays_date.month, todays_date.day, todays_date.year)
25+
print(todays_date.weekday())
2626

2727
# ISO format is a string format, yyyy-mm-dd
2828
# ---------------------------
2929
# date_object.isoformat() does the same thing as str(date_object)
3030

3131
from datetime import date
32-
d1 = date.fromisoformat('2011-11-23')
33-
print(d1)
34-
print(str(d1))
35-
print(d1.isoformat())
36-
d1
32+
todays_date = date.fromisoformat('2011-11-23')
33+
print(todays_date)
34+
print(str(todays_date))
35+
print(todays_date.isoformat())
36+
todays_date
3737

3838
# Comparison, addition and sutraction of dates
3939
# ---------------------------
@@ -42,10 +42,10 @@
4242
# The same comparison and add/subtract operations can be used with time objects.
4343

4444
from datetime import date
45-
d1 = date.today()
45+
todays_date = date.today()
4646
d2 = date(2015, 5, 14)
47-
print(d1 > d2)
48-
print(d1 - d2)
47+
print(todays_date > d2)
48+
print(todays_date - d2)
4949

5050
# Time
5151
# ---------------------------
@@ -95,9 +95,9 @@
9595
# A timedelta can also be multiplied or divided by an integer or float
9696

9797
from datetime import timedelta, date, time
98-
d1 = date(2011, 6, 15)
98+
todays_date = date(2011, 6, 15)
9999
d2 = date(2012, 9, 18)
100-
td = d2 - d1
100+
td = d2 - todays_date
101101
print(td, type(td))
102102
print(td.total_seconds())
103103
print(td * 3)
@@ -130,4 +130,4 @@
130130
start_time = time.process_time()
131131
# do some stuff
132132
end_time = time.process_time()
133-
print('operation executed in ', end_time - start_time)
133+
print('operation executed in ', end_time - start_time)

0 commit comments

Comments
 (0)