File size: 1,117 Bytes
1c87f53
df0d1ca
 
 
 
 
 
 
 
 
fa3f9b5
 
 
df0d1ca
 
fa3f9b5
 
1c87f53
 
bad2587
1c87f53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9ec0cd6
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
from datetime import datetime


def format_time(time: dict) -> str:
    """
    Format time dictionary to string.
    :param time: Time dictionary with keys 'hours' and 'minutes'.
    :return: Formatted time string in HH:MM format.
    """
    if time.get("past"):
        time = time.get("past")
        hours = int(time["hours"])
        minutes = int(time["minutes"])
        return f"{hours:02d}:{minutes:02d}"
    else:
        hours = int(time["hours"])
        minutes = int(time["minutes"])
        return f"{hours:02d}:{minutes:02d}"

def get_weekday_name(date: datetime) -> tuple:
    """
    Get the name of the weekday from its number.
    :param weekday: Weekday number (0-6).
    :return: Name of the weekday.
    """
    vietnam_weekdays = {
        0: "Thứ hai",
        1: "Thứ ba",
        2: "Thứ tư",
        3: "Thứ năm",
        4: "Thứ sáu",
        5: "Thứ bảy",
        6: "Chủ nhật"
    }
    
    weekday_ids = date.weekday()
    weekday = vietnam_weekdays.get(weekday_ids) if vietnam_weekdays.get(weekday_ids) else ""
    
    return date.strftime("%d-%m-%Y"), weekday