1
|
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
|
string of date in format YYYY-mm-dd-hh
|
9
|
"""
|
10
|
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
|
return_date = string_date[6:10] + '-' + string_date[3:5] + '-' + string_date[:2]
|
25
|
|
26
|
return return_date
|
27
|
|
28
|
|
29
|
def date_time_formatter(string_date):
|
30
|
"""
|
31
|
Converts one type of date format "dd.mm.yyyy hh.mm.ss" to date format YYYY-mm-dd-hh
|
32
|
Args:
|
33
|
string_date: string containing date in format 22.08.2018 12:27:00
|
34
|
|
35
|
Returns:
|
36
|
string of date in format YYYY-mm-dd-hh
|
37
|
"""
|
38
|
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
|
return_date = string_date[6:10] + '-' + string_date[3:5] + '-' + string_date[:2] + '-' + string_date[11:13]
|
53
|
|
54
|
return return_date
|