Skip to content

Commit 4a43608

Browse files
committed
python ex
1 parent 7dfa760 commit 4a43608

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

stepic/.DS_Store

0 Bytes
Binary file not shown.

stepic/python_fullstack/date_time.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
from datetime import date, time, datetime
2+
3+
d1 = date.today()
4+
# print(d1)
5+
6+
t1 = time(6, 30, 00)
7+
# print(t1)
8+
9+
dt1 = datetime.now()
10+
print(dt1)
11+
12+
print(d1.day)
13+
print(d1.year)
14+
15+
print(t1.hour)
16+
17+
days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
18+
19+
print(dt1.month)
20+
print(dt1.weekday())
21+
22+
print(days[dt1.weekday()])
23+
24+
d1 = d1.replace(year=2020, month=6, day=24)
25+
t1 = t1.replace(hour=12)
26+
dt1 = dt1.replace(year=2031, month=7)
27+
print(d1)
28+
print(t1)
29+
print(dt1)
30+
31+
now = datetime.now()
32+
33+
print(now)
34+
# Days
35+
print(now.strftime("%a, %A, %w, %d"))
36+
# Months
37+
print(now.strftime("%b, %B, %m"))
38+
# Time
39+
print(now.strftime("%H, %I, %M, %S, %p"))
40+
# Local time
41+
print(now.strftime("%c"))
42+
print(now.strftime("%X"))
43+
44+
dt1 = datetime(2022, 6, 1, 12)
45+
dt2 = datetime(2022, 1, 6, 12)
46+
47+
# print(dt1>dt2)
48+
# print(dt1<dt2)
49+
50+
# delta = dt1 - dt2
51+
# print(delta)
52+
# print(delta.days)
53+
# print(delta.seconds)
54+
55+
from datetime import timedelta
56+
57+
now = datetime.now()
58+
one_month = timedelta(days=30)
59+
one_week = timedelta(weeks=1)
60+
61+
print("One month+ :", now + one_month)
62+
print("One week+ :", now + one_week)
63+
print("One week- :", now - one_week)

0 commit comments

Comments
 (0)