Repository navigation
Expand file tree
/
Copy pathdatatypes.py
More file actions
66 lines (46 loc) · 1.45 KB
/
Copy pathdatatypes.py
File metadata and controls
66 lines (46 loc) · 1.45 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
"""Datatypes converters for matchers."""
def ts_truncate_seconds(timestamp):
"""
Set seconds to zero in a timestamp.
:param ts: Timestamp in seconds.
:type ts: int
:return: Timestamp in seconds, but without counting them (ie: DD-MM-YY HH:MM:00)
:rtype: int
"""
return timestamp - (timestamp % 60)
def ts_truncate_time(timestamp):
"""
Set time to zero in a timestamp.
:param ts: Timestamp in seconds.
:type ts: int
:return: Timestamp in seconds, without counting time (ie: DD-MM-YYYY 00:00:00)
:rtype: int
"""
return timestamp - (timestamp % 86400)
def java_ts_to_secs(java_ts):
"""
Convert java timestamp into unix timestamp.
:param java_ts: java timestamp in milliseconds.
:type java_ts: int
:return: Timestamp in seconds.
:rtype: int
"""
return java_ts / 1000
def java_ts_truncate_seconds(java_ts):
"""
Set seconds to zero in a timestamp.
:param ts: Timestamp in seconds.
:type ts: int
:return: Timestamp in seconds, but without counting them (ie: DD-MM-YY HH:MM:00)
:rtype: int
"""
return ts_truncate_seconds(java_ts_to_secs(java_ts))
def java_ts_truncate_time(java_ts):
"""
Set time to zero in a timestamp.
:param ts: Timestamp in seconds.
:type ts: int
:return: Timestamp in seconds, without counting time (ie: DD-MM-YYYY 00:00:00)
:rtype: int
"""
return ts_truncate_time(java_ts_to_secs(java_ts))