Projekt

Obecné

Profil

Stáhnout (1.31 KB) Statistiky
| Větev: | Revize:
1 af7609b5 Tomáš Ballák
def date_formatter(string_date: str) -> str:
2 04a2b5a4 petrh
    """
3
4
    Args:
5
        string_date: string containing date in format 22.08.2018 12:27:00
6
7
    Returns:
8 d6d75a03 petrh
        string of date in format YYYY-mm-dd-hh
9 04a2b5a4 petrh
    """
10 c8f3051b petrh
    if string_date[11].isspace():
11
        pos = 0
12
        srr = ""
13
        for i in string_date:
14
15
            if pos == 10:
16
                srr = srr + '0'
17
            else:
18
                srr = srr + i
19
20
            pos = pos + 1
21
22
        string_date = srr
23
24 af7609b5 Tomáš Ballák
    return_date = string_date[6:10] + '-' + string_date[
25
        3:5] + '-' + string_date[:2]
26 c8f3051b petrh
27
    return return_date
28
29
30 af7609b5 Tomáš Ballák
def date_time_formatter(string_date: str) -> str:
31 04a2b5a4 petrh
    """
32 d6d75a03 petrh
    Converts one type of date format "dd.mm.yyyy hh.mm.ss" to date format YYYY-mm-dd-hh
33 04a2b5a4 petrh
    Args:
34
        string_date: string containing date in format 22.08.2018 12:27:00
35
36
    Returns:
37 d6d75a03 petrh
        string of date in format YYYY-mm-dd-hh
38 04a2b5a4 petrh
    """
39 c8f3051b petrh
    if string_date[11].isspace():
40
        pos = 0
41
        srr = ""
42
        for i in string_date:
43
44
            if pos == 10:
45
                srr = srr + '0'
46
            else:
47
                srr = srr + i
48
49
            pos = pos + 1
50
51
        string_date = srr
52
53 af7609b5 Tomáš Ballák
    return_date = string_date[6:10] + '-' + string_date[
54
        3:5] + '-' + string_date[:2] + '-' + string_date[11:13]
55 c8f3051b petrh
56 04a2b5a4 petrh
    return return_date