-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_week_date.py
42 lines (33 loc) · 1.08 KB
/
check_week_date.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Check week number of your birth date (then translate your week day to Spanish)
import datetime
import calendar
# match case only if you have python 3.10 or upper
def translate_to_spanish(day_name: str):
match day_name:
case 'Monday':
return 'Lunes'
case 'Tuesday':
return 'Martes'
case 'Wednesday':
return 'Miércoles'
case 'Thursday':
return 'Jueves'
case 'Friday':
return 'Viernes'
case 'Saturday':
return 'Sábado'
case 'Sunday':
return 'Domingo'
date_of_birth = input("Enter your date of birth in the format day-month-year (e.g. 1-1-2000): ")
# unpacking the data
day, month, year = date_of_birth.split("-") # (1, 1, 2000)
# variable override
# convert str to int
date_of_birth = datetime.datetime(int(year), int(month), int(day))
# show the day of week (int)
print(date_of_birth.weekday())
# show the day of week (name)
day_name = calendar.day_name[date_of_birth.weekday()]
print(day_name)
# translate day name
print(translate_to_spanish(day_name))