Projekt

Obecné

Profil

Stáhnout (1.27 KB) Statistiky
| Větev: | Revize:
1 04a2b5a4 petrh
def date_formatter(string_date):
2
    """
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 d6d75a03 petrh
    return_date = string_date[6:10] + '-' + string_date[3:5] + '-' + string_date[:2]
25 c8f3051b petrh
26
    return return_date
27
28
29 04a2b5a4 petrh
def date_time_formatter(string_date):
30
    """
31 d6d75a03 petrh
    Converts one type of date format "dd.mm.yyyy hh.mm.ss" to date format YYYY-mm-dd-hh
32 04a2b5a4 petrh
    Args:
33
        string_date: string containing date in format 22.08.2018 12:27:00
34
35
    Returns:
36 d6d75a03 petrh
        string of date in format YYYY-mm-dd-hh
37 04a2b5a4 petrh
    """
38 c8f3051b petrh
    if string_date[11].isspace():
39
        pos = 0
40
        srr = ""
41
        for i in string_date:
42
43
            if pos == 10:
44
                srr = srr + '0'
45
            else:
46
                srr = srr + i
47
48
            pos = pos + 1
49
50
        string_date = srr
51
52 d6d75a03 petrh
    return_date = string_date[6:10] + '-' + string_date[3:5] + '-' + string_date[:2] + '-' + string_date[11:13]
53 c8f3051b petrh
54 04a2b5a4 petrh
    return return_date