python-time-functions 2.1.4__tar.gz → 2.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_time_functions-2.1.4/src/python_time_functions.egg-info → python_time_functions-2.3.0}/PKG-INFO +3 -5
- {python_time_functions-2.1.4 → python_time_functions-2.3.0}/README.md +2 -2
- {python_time_functions-2.1.4 → python_time_functions-2.3.0}/pyproject.toml +1 -3
- {python_time_functions-2.1.4 → python_time_functions-2.3.0/src/python_time_functions.egg-info}/PKG-INFO +3 -5
- {python_time_functions-2.1.4 → python_time_functions-2.3.0}/src/python_time_functions.egg-info/SOURCES.txt +1 -2
- python_time_functions-2.3.0/tests/test_time_function_sanitizer.py +64 -0
- python_time_functions-2.3.0/tests/test_time_functions.py +219 -0
- python_time_functions-2.1.4/src/python_time_functions.egg-info/requires.txt +0 -2
- python_time_functions-2.1.4/tests/test_time_function_sanitizer.py +0 -64
- python_time_functions-2.1.4/tests/test_time_functions.py +0 -219
- {python_time_functions-2.1.4 → python_time_functions-2.3.0}/LICENSE +0 -0
- {python_time_functions-2.1.4 → python_time_functions-2.3.0}/setup.cfg +0 -0
- {python_time_functions-2.1.4 → python_time_functions-2.3.0}/src/python_time_functions.egg-info/dependency_links.txt +0 -0
- {python_time_functions-2.1.4 → python_time_functions-2.3.0}/src/python_time_functions.egg-info/top_level.txt +0 -0
- {python_time_functions-2.1.4 → python_time_functions-2.3.0}/src/time_functions/__init__.py +0 -0
- /python_time_functions-2.1.4/src/time_functions/time_functions.py → /python_time_functions-2.3.0/src/time_functions/functions.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python_time_functions
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
4
4
|
Summary: Common Python functions for time handling
|
|
5
5
|
Author-email: Corne Bester <corne.bester@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://example.com
|
|
@@ -11,8 +11,6 @@ Project-URL: Changelog, https://github.com/cornebester/python_time_functions/blo
|
|
|
11
11
|
Requires-Python: >=3.10
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
|
-
Requires-Dist: datetime
|
|
15
|
-
Requires-Dist: timezone
|
|
16
14
|
Dynamic: license-file
|
|
17
15
|
|
|
18
16
|
# Readme
|
|
@@ -22,9 +20,9 @@ Common Python functions for time handling
|
|
|
22
20
|
```python
|
|
23
21
|
from datetime import datetime, timezone
|
|
24
22
|
|
|
25
|
-
import time_functions
|
|
23
|
+
import time_functions.time_functions as time_functions
|
|
26
24
|
# OR
|
|
27
|
-
from time_functions import get_timestamp_unix_millis
|
|
25
|
+
from time_functions.time_functions import get_timestamp_unix_millis
|
|
28
26
|
|
|
29
27
|
timestamp = datetime.now(timezone.utc)
|
|
30
28
|
unix_millis = get_timestamp_unix_millis(timestamp) # create unix timestamp from obj above
|
|
@@ -5,9 +5,9 @@ Common Python functions for time handling
|
|
|
5
5
|
```python
|
|
6
6
|
from datetime import datetime, timezone
|
|
7
7
|
|
|
8
|
-
import time_functions
|
|
8
|
+
import time_functions.time_functions as time_functions
|
|
9
9
|
# OR
|
|
10
|
-
from time_functions import get_timestamp_unix_millis
|
|
10
|
+
from time_functions.time_functions import get_timestamp_unix_millis
|
|
11
11
|
|
|
12
12
|
timestamp = datetime.now(timezone.utc)
|
|
13
13
|
unix_millis = get_timestamp_unix_millis(timestamp) # create unix timestamp from obj above
|
|
@@ -4,14 +4,12 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "python_time_functions"
|
|
7
|
-
version = "2.
|
|
7
|
+
version = "2.3.0"
|
|
8
8
|
description = "Common Python functions for time handling"
|
|
9
9
|
requires-python = ">=3.10"
|
|
10
10
|
readme = "README.md"
|
|
11
11
|
authors = [{name = "Corne Bester", email = "corne.bester@gmail.com"}]
|
|
12
12
|
dependencies = [
|
|
13
|
-
"datetime",
|
|
14
|
-
"timezone"
|
|
15
13
|
]
|
|
16
14
|
license-files = ["LICEN[CS]E*"]
|
|
17
15
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python_time_functions
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
4
4
|
Summary: Common Python functions for time handling
|
|
5
5
|
Author-email: Corne Bester <corne.bester@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://example.com
|
|
@@ -11,8 +11,6 @@ Project-URL: Changelog, https://github.com/cornebester/python_time_functions/blo
|
|
|
11
11
|
Requires-Python: >=3.10
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
|
-
Requires-Dist: datetime
|
|
15
|
-
Requires-Dist: timezone
|
|
16
14
|
Dynamic: license-file
|
|
17
15
|
|
|
18
16
|
# Readme
|
|
@@ -22,9 +20,9 @@ Common Python functions for time handling
|
|
|
22
20
|
```python
|
|
23
21
|
from datetime import datetime, timezone
|
|
24
22
|
|
|
25
|
-
import time_functions
|
|
23
|
+
import time_functions.time_functions as time_functions
|
|
26
24
|
# OR
|
|
27
|
-
from time_functions import get_timestamp_unix_millis
|
|
25
|
+
from time_functions.time_functions import get_timestamp_unix_millis
|
|
28
26
|
|
|
29
27
|
timestamp = datetime.now(timezone.utc)
|
|
30
28
|
unix_millis = get_timestamp_unix_millis(timestamp) # create unix timestamp from obj above
|
|
@@ -4,9 +4,8 @@ pyproject.toml
|
|
|
4
4
|
src/python_time_functions.egg-info/PKG-INFO
|
|
5
5
|
src/python_time_functions.egg-info/SOURCES.txt
|
|
6
6
|
src/python_time_functions.egg-info/dependency_links.txt
|
|
7
|
-
src/python_time_functions.egg-info/requires.txt
|
|
8
7
|
src/python_time_functions.egg-info/top_level.txt
|
|
9
8
|
src/time_functions/__init__.py
|
|
10
|
-
src/time_functions/
|
|
9
|
+
src/time_functions/functions.py
|
|
11
10
|
tests/test_time_function_sanitizer.py
|
|
12
11
|
tests/test_time_functions.py
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import src.time_functions.functions as functions
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def test_convertions_from_sample24():
|
|
5
|
+
"""
|
|
6
|
+
# unix seconds
|
|
7
|
+
"""
|
|
8
|
+
assert functions.timestamp_sanitizer_psql(1742758997) == 1742758997
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def test_convertions_from_sample25():
|
|
12
|
+
"""
|
|
13
|
+
# unix millis
|
|
14
|
+
"""
|
|
15
|
+
assert functions.timestamp_sanitizer_psql(1742758997018) == 1742758997.018
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def test_convertions_from_sample26():
|
|
19
|
+
"""
|
|
20
|
+
# unix micros
|
|
21
|
+
"""
|
|
22
|
+
assert functions.timestamp_sanitizer_psql(1742758997018308) == 1742758997.018
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def test_convertions_from_sample27():
|
|
26
|
+
"""
|
|
27
|
+
# unix micros
|
|
28
|
+
"""
|
|
29
|
+
assert functions.timestamp_sanitizer_psql(1742758997018308) == 1742758997.018
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def test_convertions_from_sample28():
|
|
33
|
+
"""
|
|
34
|
+
# psql special
|
|
35
|
+
"""
|
|
36
|
+
assert functions.timestamp_sanitizer_psql(1742758997.018308) == 1742758997.018
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def test_convertions_from_sample29():
|
|
40
|
+
"""
|
|
41
|
+
# psql special
|
|
42
|
+
"""
|
|
43
|
+
assert functions.timestamp_sanitizer_psql(1742758997.018) == 1742758997.018
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def test_convertions_from_sample30():
|
|
47
|
+
"""
|
|
48
|
+
# bad format
|
|
49
|
+
"""
|
|
50
|
+
assert functions.timestamp_sanitizer_psql(1742758997018.308) == 1742758997.018
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def test_convertions_from_sample31():
|
|
54
|
+
"""
|
|
55
|
+
# bad format
|
|
56
|
+
"""
|
|
57
|
+
assert (
|
|
58
|
+
functions.timestamp_sanitizer_psql("2025-03-23T19:43:17.018Z")
|
|
59
|
+
== 1742758997.018
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def test_convertions_from_sample32():
|
|
64
|
+
assert functions.timestamp_sanitizer_psql(1742742625002.908) == 1742742625.002
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
from datetime import datetime, timezone
|
|
2
|
+
import src.time_functions.functions as functions
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
new_obj = datetime.now(timezone.utc)
|
|
6
|
+
|
|
7
|
+
iso = functions.get_timestamp_iso8601(new_obj)
|
|
8
|
+
iso_millis = functions.get_timestamp_iso8601_millis(new_obj)
|
|
9
|
+
iso_micros = functions.get_timestamp_iso8601_micros(new_obj)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
unix = functions.get_timestamp_unix(new_obj)
|
|
13
|
+
unix_millis = functions.get_timestamp_unix_millis(new_obj)
|
|
14
|
+
unix_micros = functions.get_timestamp_unix_micros(new_obj)
|
|
15
|
+
unix_with_subseconds = functions.get_timestamp_unix_subseconds_decimal(new_obj)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
obj_from_iso = functions.convert_iso_string_to_datetime_obj(iso)
|
|
19
|
+
obj_from_iso_millis = functions.convert_iso_string_to_datetime_obj(iso_millis)
|
|
20
|
+
obj_from_iso_micros = functions.convert_iso_string_to_datetime_obj(iso_micros)
|
|
21
|
+
|
|
22
|
+
obj_from_unix_seconds = functions.convert_unix_to_datetime_obj(unix)
|
|
23
|
+
obj_from_unix_milliseconds = functions.convert_unix_to_datetime_obj(unix_millis)
|
|
24
|
+
obj_from_unix_microseconds = functions.convert_unix_to_datetime_obj(unix_micros)
|
|
25
|
+
|
|
26
|
+
obj_from_unix_seconds_float_millis = functions.convert_unix_to_datetime_obj(
|
|
27
|
+
unix_millis / 1000
|
|
28
|
+
)
|
|
29
|
+
obj_from_unix_seconds_float_micros = functions.convert_unix_to_datetime_obj(
|
|
30
|
+
unix_micros / 1000000
|
|
31
|
+
)
|
|
32
|
+
obj_from_unix_seconds_float = functions.convert_unix_to_datetime_obj(
|
|
33
|
+
unix_with_subseconds
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def test_convertions_from_sample():
|
|
38
|
+
assert functions.convert_unix_to_datetime_obj(
|
|
39
|
+
1742736574
|
|
40
|
+
) == functions.convert_iso_string_to_datetime_obj("2025-03-23T13:29:34+00:00")
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def test_convertions_from_sample2():
|
|
44
|
+
assert functions.convert_unix_to_datetime_obj(
|
|
45
|
+
1742737159020
|
|
46
|
+
) == functions.convert_iso_string_to_datetime_obj("2025-03-23T13:39:19.020Z")
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def test_convertions_from_sample3():
|
|
50
|
+
assert functions.convert_unix_to_datetime_obj(
|
|
51
|
+
1742737771434946
|
|
52
|
+
) == functions.convert_iso_string_to_datetime_obj(
|
|
53
|
+
"2025-03-23T13:49:31.434946Z"
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def test_convertions_from_sample4():
|
|
58
|
+
assert functions.convert_unix_to_datetime_obj(
|
|
59
|
+
unix
|
|
60
|
+
) == functions.convert_iso_string_to_datetime_obj(iso)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def test_convertions_from_sample5():
|
|
64
|
+
assert functions.convert_unix_to_datetime_obj(
|
|
65
|
+
unix_millis
|
|
66
|
+
) == functions.convert_iso_string_to_datetime_obj(iso_millis)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def test_convertions_from_sample6():
|
|
70
|
+
assert functions.convert_unix_to_datetime_obj(
|
|
71
|
+
unix_micros
|
|
72
|
+
) == functions.convert_iso_string_to_datetime_obj(iso_micros)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def test_convertions_from_sample7():
|
|
76
|
+
assert obj_from_iso == obj_from_unix_seconds
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def test_convertions_from_sample8():
|
|
80
|
+
assert obj_from_iso_millis == obj_from_unix_milliseconds
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def test_convertions_from_sample9():
|
|
84
|
+
assert obj_from_iso_micros == obj_from_unix_microseconds
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def test_convertions_from_sample10():
|
|
88
|
+
assert obj_from_iso_millis == obj_from_unix_seconds_float_millis
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def test_convertions_from_sample11():
|
|
92
|
+
assert obj_from_iso_micros == obj_from_unix_seconds_float_micros
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def test_convertions_from_sample12():
|
|
96
|
+
assert obj_from_iso_micros == obj_from_unix_seconds_float
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def test_convertions_from_sample13():
|
|
100
|
+
assert functions.convert_unix_to_datetime_obj(
|
|
101
|
+
unix_with_subseconds
|
|
102
|
+
) == functions.convert_iso_string_to_datetime_obj(iso_micros)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def test_convertions_from_sample14():
|
|
106
|
+
"""
|
|
107
|
+
# obj_from_iso = time_functions.convert_iso_string_to_datetime_obj("2025-03-23T15:10:25Z")
|
|
108
|
+
# unix_with_subseconds = int(time_functions.get_timestamp_unix_subseconds_decimal(obj_from_iso))
|
|
109
|
+
# unix_with_subseconds == 1742742625
|
|
110
|
+
"""
|
|
111
|
+
assert (
|
|
112
|
+
functions.timestamp_parser_psql_millis("2025-03-23T15:10:25Z")
|
|
113
|
+
== 1742742625
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def test_convertions_from_sample15():
|
|
118
|
+
"""
|
|
119
|
+
# obj_from_iso = time_functions.convert_iso_string_to_datetime_obj("2025-03-23T15:10:25.002Z")
|
|
120
|
+
# unix_with_subseconds = time_functions.get_timestamp_unix_subseconds_decimal(obj_from_iso)
|
|
121
|
+
# unix_with_subseconds == 1742742625.002
|
|
122
|
+
"""
|
|
123
|
+
assert (
|
|
124
|
+
functions.timestamp_parser_psql_millis("2025-03-23T15:10:25.002Z")
|
|
125
|
+
== 1742742625.002
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def test_convertions_from_sample16():
|
|
130
|
+
"""
|
|
131
|
+
# obj_from_iso = time_functions.convert_iso_string_to_datetime_obj("2025-03-23T15:10:25.002908Z")
|
|
132
|
+
# unix_with_subseconds = time_functions.get_timestamp_unix_subseconds_decimal(obj_from_iso)
|
|
133
|
+
# unix_with_subseconds == 1742742625.002908
|
|
134
|
+
"""
|
|
135
|
+
assert (
|
|
136
|
+
functions.timestamp_parser_psql_millis("2025-03-23T15:10:25.002908Z")
|
|
137
|
+
== 1742742625.002
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def test_convertions_from_sample17():
|
|
142
|
+
assert functions.timestamp_parser_psql_millis(1742742625) == 1742742625
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def test_convertions_from_sample18():
|
|
146
|
+
"""
|
|
147
|
+
postgresql timeformat
|
|
148
|
+
"""
|
|
149
|
+
assert functions.timestamp_parser_psql_millis(1742742625.0) == 1742742625.0
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def test_convertions_from_sample19():
|
|
153
|
+
"""
|
|
154
|
+
postgresql timeformat
|
|
155
|
+
"""
|
|
156
|
+
assert functions.timestamp_parser_psql_millis(1742742625.002) == 1742742625.002
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def test_convertions_from_sample20():
|
|
160
|
+
"""
|
|
161
|
+
postgresql timeformat
|
|
162
|
+
"""
|
|
163
|
+
assert (
|
|
164
|
+
functions.timestamp_parser_psql_millis(1742742625.002908) == 1742742625.002
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def test_convertions_from_sample21():
|
|
169
|
+
"""
|
|
170
|
+
python millis timeformat
|
|
171
|
+
"""
|
|
172
|
+
assert functions.timestamp_parser_psql_millis(1742742625002) == 1742742625.002
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def test_convertions_from_sample22():
|
|
176
|
+
"""
|
|
177
|
+
python micros timeformat
|
|
178
|
+
"""
|
|
179
|
+
assert (
|
|
180
|
+
functions.timestamp_parser_psql_millis(1742742625002908) == 1742742625.002
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def test_convertions_from_sample33():
|
|
185
|
+
"""
|
|
186
|
+
postgresql nano timeformat
|
|
187
|
+
"""
|
|
188
|
+
assert (
|
|
189
|
+
functions.timestamp_parser_psql_millis(1742742625.002908123)
|
|
190
|
+
== 1742742625.002
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def test_convertions_from_sample32():
|
|
195
|
+
"""
|
|
196
|
+
bad timeformat
|
|
197
|
+
"""
|
|
198
|
+
assert functions.timestamp_parser_psql_millis(1742742625002.908) is None
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
def test_convertions_from_sample34():
|
|
202
|
+
"""
|
|
203
|
+
bad timeformat
|
|
204
|
+
"""
|
|
205
|
+
assert functions.timestamp_sanitizer_psql(1729755232184) == 1729755232.184
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def test_convertions_from_sample35():
|
|
209
|
+
"""
|
|
210
|
+
bad timeformat
|
|
211
|
+
"""
|
|
212
|
+
assert functions.timestamp_sanitizer_psql(1729765227856.3) == 1729765227.856
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
def test_convertions_from_sample36():
|
|
216
|
+
"""
|
|
217
|
+
bad timeformat
|
|
218
|
+
"""
|
|
219
|
+
assert functions.timestamp_sanitizer_psql(1729765228327.051) == 1729765228.327
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import src.time_functions.time_functions as time_functions
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def test_convertions_from_sample24():
|
|
5
|
-
"""
|
|
6
|
-
# unix seconds
|
|
7
|
-
"""
|
|
8
|
-
assert time_functions.timestamp_sanitizer_psql(1742758997) == 1742758997
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def test_convertions_from_sample25():
|
|
12
|
-
"""
|
|
13
|
-
# unix millis
|
|
14
|
-
"""
|
|
15
|
-
assert time_functions.timestamp_sanitizer_psql(1742758997018) == 1742758997.018
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def test_convertions_from_sample26():
|
|
19
|
-
"""
|
|
20
|
-
# unix micros
|
|
21
|
-
"""
|
|
22
|
-
assert time_functions.timestamp_sanitizer_psql(1742758997018308) == 1742758997.018
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def test_convertions_from_sample27():
|
|
26
|
-
"""
|
|
27
|
-
# unix micros
|
|
28
|
-
"""
|
|
29
|
-
assert time_functions.timestamp_sanitizer_psql(1742758997018308) == 1742758997.018
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
def test_convertions_from_sample28():
|
|
33
|
-
"""
|
|
34
|
-
# psql special
|
|
35
|
-
"""
|
|
36
|
-
assert time_functions.timestamp_sanitizer_psql(1742758997.018308) == 1742758997.018
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
def test_convertions_from_sample29():
|
|
40
|
-
"""
|
|
41
|
-
# psql special
|
|
42
|
-
"""
|
|
43
|
-
assert time_functions.timestamp_sanitizer_psql(1742758997.018) == 1742758997.018
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
def test_convertions_from_sample30():
|
|
47
|
-
"""
|
|
48
|
-
# bad format
|
|
49
|
-
"""
|
|
50
|
-
assert time_functions.timestamp_sanitizer_psql(1742758997018.308) == 1742758997.018
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
def test_convertions_from_sample31():
|
|
54
|
-
"""
|
|
55
|
-
# bad format
|
|
56
|
-
"""
|
|
57
|
-
assert (
|
|
58
|
-
time_functions.timestamp_sanitizer_psql("2025-03-23T19:43:17.018Z")
|
|
59
|
-
== 1742758997.018
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
def test_convertions_from_sample32():
|
|
64
|
-
assert time_functions.timestamp_sanitizer_psql(1742742625002.908) == 1742742625.002
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
from datetime import datetime, timezone
|
|
2
|
-
import src.time_functions.time_functions as time_functions
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
new_obj = datetime.now(timezone.utc)
|
|
6
|
-
|
|
7
|
-
iso = time_functions.get_timestamp_iso8601(new_obj)
|
|
8
|
-
iso_millis = time_functions.get_timestamp_iso8601_millis(new_obj)
|
|
9
|
-
iso_micros = time_functions.get_timestamp_iso8601_micros(new_obj)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
unix = time_functions.get_timestamp_unix(new_obj)
|
|
13
|
-
unix_millis = time_functions.get_timestamp_unix_millis(new_obj)
|
|
14
|
-
unix_micros = time_functions.get_timestamp_unix_micros(new_obj)
|
|
15
|
-
unix_with_subseconds = time_functions.get_timestamp_unix_subseconds_decimal(new_obj)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
obj_from_iso = time_functions.convert_iso_string_to_datetime_obj(iso)
|
|
19
|
-
obj_from_iso_millis = time_functions.convert_iso_string_to_datetime_obj(iso_millis)
|
|
20
|
-
obj_from_iso_micros = time_functions.convert_iso_string_to_datetime_obj(iso_micros)
|
|
21
|
-
|
|
22
|
-
obj_from_unix_seconds = time_functions.convert_unix_to_datetime_obj(unix)
|
|
23
|
-
obj_from_unix_milliseconds = time_functions.convert_unix_to_datetime_obj(unix_millis)
|
|
24
|
-
obj_from_unix_microseconds = time_functions.convert_unix_to_datetime_obj(unix_micros)
|
|
25
|
-
|
|
26
|
-
obj_from_unix_seconds_float_millis = time_functions.convert_unix_to_datetime_obj(
|
|
27
|
-
unix_millis / 1000
|
|
28
|
-
)
|
|
29
|
-
obj_from_unix_seconds_float_micros = time_functions.convert_unix_to_datetime_obj(
|
|
30
|
-
unix_micros / 1000000
|
|
31
|
-
)
|
|
32
|
-
obj_from_unix_seconds_float = time_functions.convert_unix_to_datetime_obj(
|
|
33
|
-
unix_with_subseconds
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def test_convertions_from_sample():
|
|
38
|
-
assert time_functions.convert_unix_to_datetime_obj(
|
|
39
|
-
1742736574
|
|
40
|
-
) == time_functions.convert_iso_string_to_datetime_obj("2025-03-23T13:29:34+00:00")
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
def test_convertions_from_sample2():
|
|
44
|
-
assert time_functions.convert_unix_to_datetime_obj(
|
|
45
|
-
1742737159020
|
|
46
|
-
) == time_functions.convert_iso_string_to_datetime_obj("2025-03-23T13:39:19.020Z")
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
def test_convertions_from_sample3():
|
|
50
|
-
assert time_functions.convert_unix_to_datetime_obj(
|
|
51
|
-
1742737771434946
|
|
52
|
-
) == time_functions.convert_iso_string_to_datetime_obj(
|
|
53
|
-
"2025-03-23T13:49:31.434946Z"
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
def test_convertions_from_sample4():
|
|
58
|
-
assert time_functions.convert_unix_to_datetime_obj(
|
|
59
|
-
unix
|
|
60
|
-
) == time_functions.convert_iso_string_to_datetime_obj(iso)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
def test_convertions_from_sample5():
|
|
64
|
-
assert time_functions.convert_unix_to_datetime_obj(
|
|
65
|
-
unix_millis
|
|
66
|
-
) == time_functions.convert_iso_string_to_datetime_obj(iso_millis)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
def test_convertions_from_sample6():
|
|
70
|
-
assert time_functions.convert_unix_to_datetime_obj(
|
|
71
|
-
unix_micros
|
|
72
|
-
) == time_functions.convert_iso_string_to_datetime_obj(iso_micros)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
def test_convertions_from_sample7():
|
|
76
|
-
assert obj_from_iso == obj_from_unix_seconds
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
def test_convertions_from_sample8():
|
|
80
|
-
assert obj_from_iso_millis == obj_from_unix_milliseconds
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
def test_convertions_from_sample9():
|
|
84
|
-
assert obj_from_iso_micros == obj_from_unix_microseconds
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
def test_convertions_from_sample10():
|
|
88
|
-
assert obj_from_iso_millis == obj_from_unix_seconds_float_millis
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
def test_convertions_from_sample11():
|
|
92
|
-
assert obj_from_iso_micros == obj_from_unix_seconds_float_micros
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
def test_convertions_from_sample12():
|
|
96
|
-
assert obj_from_iso_micros == obj_from_unix_seconds_float
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
def test_convertions_from_sample13():
|
|
100
|
-
assert time_functions.convert_unix_to_datetime_obj(
|
|
101
|
-
unix_with_subseconds
|
|
102
|
-
) == time_functions.convert_iso_string_to_datetime_obj(iso_micros)
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
def test_convertions_from_sample14():
|
|
106
|
-
"""
|
|
107
|
-
# obj_from_iso = time_functions.convert_iso_string_to_datetime_obj("2025-03-23T15:10:25Z")
|
|
108
|
-
# unix_with_subseconds = int(time_functions.get_timestamp_unix_subseconds_decimal(obj_from_iso))
|
|
109
|
-
# unix_with_subseconds == 1742742625
|
|
110
|
-
"""
|
|
111
|
-
assert (
|
|
112
|
-
time_functions.timestamp_parser_psql_millis("2025-03-23T15:10:25Z")
|
|
113
|
-
== 1742742625
|
|
114
|
-
)
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
def test_convertions_from_sample15():
|
|
118
|
-
"""
|
|
119
|
-
# obj_from_iso = time_functions.convert_iso_string_to_datetime_obj("2025-03-23T15:10:25.002Z")
|
|
120
|
-
# unix_with_subseconds = time_functions.get_timestamp_unix_subseconds_decimal(obj_from_iso)
|
|
121
|
-
# unix_with_subseconds == 1742742625.002
|
|
122
|
-
"""
|
|
123
|
-
assert (
|
|
124
|
-
time_functions.timestamp_parser_psql_millis("2025-03-23T15:10:25.002Z")
|
|
125
|
-
== 1742742625.002
|
|
126
|
-
)
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
def test_convertions_from_sample16():
|
|
130
|
-
"""
|
|
131
|
-
# obj_from_iso = time_functions.convert_iso_string_to_datetime_obj("2025-03-23T15:10:25.002908Z")
|
|
132
|
-
# unix_with_subseconds = time_functions.get_timestamp_unix_subseconds_decimal(obj_from_iso)
|
|
133
|
-
# unix_with_subseconds == 1742742625.002908
|
|
134
|
-
"""
|
|
135
|
-
assert (
|
|
136
|
-
time_functions.timestamp_parser_psql_millis("2025-03-23T15:10:25.002908Z")
|
|
137
|
-
== 1742742625.002
|
|
138
|
-
)
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
def test_convertions_from_sample17():
|
|
142
|
-
assert time_functions.timestamp_parser_psql_millis(1742742625) == 1742742625
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
def test_convertions_from_sample18():
|
|
146
|
-
"""
|
|
147
|
-
postgresql timeformat
|
|
148
|
-
"""
|
|
149
|
-
assert time_functions.timestamp_parser_psql_millis(1742742625.0) == 1742742625.0
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
def test_convertions_from_sample19():
|
|
153
|
-
"""
|
|
154
|
-
postgresql timeformat
|
|
155
|
-
"""
|
|
156
|
-
assert time_functions.timestamp_parser_psql_millis(1742742625.002) == 1742742625.002
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
def test_convertions_from_sample20():
|
|
160
|
-
"""
|
|
161
|
-
postgresql timeformat
|
|
162
|
-
"""
|
|
163
|
-
assert (
|
|
164
|
-
time_functions.timestamp_parser_psql_millis(1742742625.002908) == 1742742625.002
|
|
165
|
-
)
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
def test_convertions_from_sample21():
|
|
169
|
-
"""
|
|
170
|
-
python millis timeformat
|
|
171
|
-
"""
|
|
172
|
-
assert time_functions.timestamp_parser_psql_millis(1742742625002) == 1742742625.002
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
def test_convertions_from_sample22():
|
|
176
|
-
"""
|
|
177
|
-
python micros timeformat
|
|
178
|
-
"""
|
|
179
|
-
assert (
|
|
180
|
-
time_functions.timestamp_parser_psql_millis(1742742625002908) == 1742742625.002
|
|
181
|
-
)
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
def test_convertions_from_sample33():
|
|
185
|
-
"""
|
|
186
|
-
postgresql nano timeformat
|
|
187
|
-
"""
|
|
188
|
-
assert (
|
|
189
|
-
time_functions.timestamp_parser_psql_millis(1742742625.002908123)
|
|
190
|
-
== 1742742625.002
|
|
191
|
-
)
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
def test_convertions_from_sample32():
|
|
195
|
-
"""
|
|
196
|
-
bad timeformat
|
|
197
|
-
"""
|
|
198
|
-
assert time_functions.timestamp_parser_psql_millis(1742742625002.908) is None
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
def test_convertions_from_sample34():
|
|
202
|
-
"""
|
|
203
|
-
bad timeformat
|
|
204
|
-
"""
|
|
205
|
-
assert time_functions.timestamp_sanitizer_psql(1729755232184) == 1729755232.184
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
def test_convertions_from_sample35():
|
|
209
|
-
"""
|
|
210
|
-
bad timeformat
|
|
211
|
-
"""
|
|
212
|
-
assert time_functions.timestamp_sanitizer_psql(1729765227856.3) == 1729765227.856
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
def test_convertions_from_sample36():
|
|
216
|
-
"""
|
|
217
|
-
bad timeformat
|
|
218
|
-
"""
|
|
219
|
-
assert time_functions.timestamp_sanitizer_psql(1729765228327.051) == 1729765228.327
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|