python-time-functions 2.1.1__tar.gz → 2.1.3__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.
Files changed (20) hide show
  1. python_time_functions-2.1.3/PKG-INFO +47 -0
  2. python_time_functions-2.1.3/README.md +31 -0
  3. python_time_functions-2.1.3/pyproject.toml +23 -0
  4. python_time_functions-2.1.3/src/python_time_functions.egg-info/PKG-INFO +47 -0
  5. {python_time_functions-2.1.1 → python_time_functions-2.1.3}/src/python_time_functions.egg-info/SOURCES.txt +3 -2
  6. python_time_functions-2.1.3/src/python_time_functions.egg-info/requires.txt +2 -0
  7. python_time_functions-2.1.3/src/python_time_functions.egg-info/top_level.txt +1 -0
  8. {python_time_functions-2.1.1/src/time_fuctions_cornebester → python_time_functions-2.1.3/src/time_functions}/time_functions.py +60 -20
  9. python_time_functions-2.1.3/tests/test_time_function_sanitizer.py +64 -0
  10. {python_time_functions-2.1.1 → python_time_functions-2.1.3}/tests/test_time_functions.py +84 -45
  11. python_time_functions-2.1.1/PKG-INFO +0 -8
  12. python_time_functions-2.1.1/README.md +0 -46
  13. python_time_functions-2.1.1/pyproject.toml +0 -14
  14. python_time_functions-2.1.1/src/python_time_functions.egg-info/PKG-INFO +0 -8
  15. python_time_functions-2.1.1/src/python_time_functions.egg-info/top_level.txt +0 -1
  16. python_time_functions-2.1.1/tests/test_time_function_sanitizer.py +0 -64
  17. {python_time_functions-2.1.1 → python_time_functions-2.1.3}/LICENSE +0 -0
  18. {python_time_functions-2.1.1 → python_time_functions-2.1.3}/setup.cfg +0 -0
  19. {python_time_functions-2.1.1 → python_time_functions-2.1.3}/src/python_time_functions.egg-info/dependency_links.txt +0 -0
  20. {python_time_functions-2.1.1/src/time_fuctions_cornebester → python_time_functions-2.1.3/src/time_functions}/__init__.py +0 -0
@@ -0,0 +1,47 @@
1
+ Metadata-Version: 2.4
2
+ Name: python_time_functions
3
+ Version: 2.1.3
4
+ Summary: Common Python functions for time handling
5
+ Author-email: Corne Bester <corne.bester@gmail.com>
6
+ Project-URL: Homepage, https://example.com
7
+ Project-URL: Documentation, https://readthedocs.org
8
+ Project-URL: Repository, https://github.com/cornebester/python_time_functions
9
+ Project-URL: Issues, https://github.com/cornebester/python_time_functions/issues
10
+ Project-URL: Changelog, https://github.com/cornebester/python_time_functions/blob/master/CHANGELOG.md
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: datetime
14
+ Requires-Dist: timezone
15
+ Dynamic: license-file
16
+
17
+ # Readme
18
+
19
+ Common Python functions for time handling
20
+
21
+ ```python
22
+ from datetime import datetime, timezone
23
+
24
+ import time_functions
25
+ # OR
26
+ from time_functions import get_timestamp_unix_millis
27
+
28
+ timestamp = datetime.now(timezone.utc)
29
+ unix_millis = get_timestamp_unix_millis(timestamp) # create unix timestamp from obj above
30
+
31
+ ```
32
+
33
+ ## local dev
34
+
35
+ pip install -r requirements.txt
36
+
37
+
38
+ ## test
39
+
40
+ pytest
41
+
42
+
43
+ ### other
44
+
45
+ pip3 freeze > requirements.txt
46
+
47
+
@@ -0,0 +1,31 @@
1
+ # Readme
2
+
3
+ Common Python functions for time handling
4
+
5
+ ```python
6
+ from datetime import datetime, timezone
7
+
8
+ import time_functions
9
+ # OR
10
+ from time_functions import get_timestamp_unix_millis
11
+
12
+ timestamp = datetime.now(timezone.utc)
13
+ unix_millis = get_timestamp_unix_millis(timestamp) # create unix timestamp from obj above
14
+
15
+ ```
16
+
17
+ ## local dev
18
+
19
+ pip install -r requirements.txt
20
+
21
+
22
+ ## test
23
+
24
+ pytest
25
+
26
+
27
+ ### other
28
+
29
+ pip3 freeze > requirements.txt
30
+
31
+
@@ -0,0 +1,23 @@
1
+ [build-system]
2
+ requires = ["setuptools>=65.5.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "python_time_functions"
7
+ version = "2.1.3"
8
+ description = "Common Python functions for time handling"
9
+ readme = "README.md"
10
+ authors = [{name = "Corne Bester", email = "corne.bester@gmail.com"}]
11
+ dependencies = [
12
+ "datetime",
13
+ "timezone"
14
+ ]
15
+ license-files = ["LICEN[CS]E*"]
16
+
17
+ [project.urls]
18
+ Homepage = "https://example.com"
19
+ Documentation = "https://readthedocs.org"
20
+ Repository = "https://github.com/cornebester/python_time_functions"
21
+ Issues = "https://github.com/cornebester/python_time_functions/issues"
22
+ Changelog = "https://github.com/cornebester/python_time_functions/blob/master/CHANGELOG.md"
23
+
@@ -0,0 +1,47 @@
1
+ Metadata-Version: 2.4
2
+ Name: python_time_functions
3
+ Version: 2.1.3
4
+ Summary: Common Python functions for time handling
5
+ Author-email: Corne Bester <corne.bester@gmail.com>
6
+ Project-URL: Homepage, https://example.com
7
+ Project-URL: Documentation, https://readthedocs.org
8
+ Project-URL: Repository, https://github.com/cornebester/python_time_functions
9
+ Project-URL: Issues, https://github.com/cornebester/python_time_functions/issues
10
+ Project-URL: Changelog, https://github.com/cornebester/python_time_functions/blob/master/CHANGELOG.md
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: datetime
14
+ Requires-Dist: timezone
15
+ Dynamic: license-file
16
+
17
+ # Readme
18
+
19
+ Common Python functions for time handling
20
+
21
+ ```python
22
+ from datetime import datetime, timezone
23
+
24
+ import time_functions
25
+ # OR
26
+ from time_functions import get_timestamp_unix_millis
27
+
28
+ timestamp = datetime.now(timezone.utc)
29
+ unix_millis = get_timestamp_unix_millis(timestamp) # create unix timestamp from obj above
30
+
31
+ ```
32
+
33
+ ## local dev
34
+
35
+ pip install -r requirements.txt
36
+
37
+
38
+ ## test
39
+
40
+ pytest
41
+
42
+
43
+ ### other
44
+
45
+ pip3 freeze > requirements.txt
46
+
47
+
@@ -4,8 +4,9 @@ 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
7
8
  src/python_time_functions.egg-info/top_level.txt
8
- src/time_fuctions_cornebester/__init__.py
9
- src/time_fuctions_cornebester/time_functions.py
9
+ src/time_functions/__init__.py
10
+ src/time_functions/time_functions.py
10
11
  tests/test_time_function_sanitizer.py
11
12
  tests/test_time_functions.py
@@ -239,58 +239,98 @@ def timestamp_parser_psql_millis(timestamp):
239
239
 
240
240
 
241
241
  def timestamp_sanitizer_psql(input):
242
- '''
242
+ """
243
243
  Normalize unix timestamps to postgresl friendly float with millisecond decimals. 14 digits
244
- Attemps to fix/sanitize bad timestamps
245
- handle timestamnp as:
244
+ Attemps to fix/sanitize bad timestamp format I dreamed up like
245
+ >>> time_functions.timestamp_sanitizer_psql(1729755232184)
246
+ 1729755232.184
247
+ >>> time_functions.timestamp_sanitizer_psql(1729765227856.3)
248
+ 1729765227.856
249
+ >>> time_functions.timestamp_sanitizer_psql(1729765228327.051)
250
+ 1729765228.327
251
+ handle timestamp as:
246
252
  unix micros or millis in decimal format
247
- unix millis or micros in unix format
253
+ unix millis or micros in unix format
248
254
  iso8601
249
- '''
255
+ """
250
256
  try:
251
257
  if isinstance(input, int):
252
258
  if len(str(input)) == 10:
253
259
  logger.debug("Not millsecond precision: %s", input)
254
260
  return input
255
261
  elif len(str(input)) == 13:
256
- normalized = str((input/1000))[:14]
257
- logger.debug("Normalizing timestamp for postgresql from %s to %s", input, normalized)
262
+ normalized = str((input / 1000))[:14]
263
+ logger.debug(
264
+ "Normalizing timestamp for postgresql from %s to %s",
265
+ input,
266
+ normalized,
267
+ )
258
268
  return float(normalized)
259
269
  elif len(str(input)) == 16:
260
- normalized = str(input/1000000)[:14]
261
- logger.debug("Normalizing timestamp for postgresql from %s to %s", input, normalized)
270
+ normalized = str(input / 1000000)[:14]
271
+ logger.debug(
272
+ "Normalizing timestamp for postgresql from %s to %s",
273
+ input,
274
+ normalized,
275
+ )
262
276
  return float(normalized)
263
277
  elif isinstance(input, float):
264
278
  # elif '.' in str(input):
265
- decimal_index = str.index(str(input), '.')
279
+ decimal_index = str.index(str(input), ".")
266
280
  if decimal_index == 13:
267
- normalized = str(input/1000)[:14] # remove microsecond precision
268
- logger.debug("Normalizing timestamp for postgresql from %s to %s", input, normalized)
281
+ normalized = str(input / 1000)[:14] # remove microsecond precision
282
+ logger.debug(
283
+ "Normalizing timestamp for postgresql from %s to %s",
284
+ input,
285
+ normalized,
286
+ )
269
287
  return float(normalized)
270
288
  elif decimal_index == 10:
271
289
  normalized = str(input)[:14] # remove microsecond precision
272
- logger.debug("Normalizing timestamp for postgresql from %s to %s", input, normalized)
290
+ logger.debug(
291
+ "Normalizing timestamp for postgresql from %s to %s",
292
+ input,
293
+ normalized,
294
+ )
273
295
  return float(normalized)
274
296
  elif isinstance(input, str):
275
297
  if len(input) == 20:
276
298
  obj_from_iso = convert_iso_string_to_datetime_obj(input)
277
- unix_with_subseconds = get_timestamp_unix_subseconds_decimal(obj_from_iso)
299
+ unix_with_subseconds = get_timestamp_unix_subseconds_decimal(
300
+ obj_from_iso
301
+ )
278
302
  normalized = unix_with_subseconds
279
- logger.debug("Normalizing timestamp for postgresql from %s to %s", input, normalized)
303
+ logger.debug(
304
+ "Normalizing timestamp for postgresql from %s to %s",
305
+ input,
306
+ normalized,
307
+ )
280
308
  return float(normalized)
281
309
  if len(input) == 24:
282
310
  obj_from_iso = convert_iso_string_to_datetime_obj(input)
283
- unix_with_subseconds = get_timestamp_unix_subseconds_decimal(obj_from_iso)
311
+ unix_with_subseconds = get_timestamp_unix_subseconds_decimal(
312
+ obj_from_iso
313
+ )
284
314
  normalized = unix_with_subseconds
285
- logger.debug("Normalizing timestamp for postgresql from %s to %s", input, normalized)
315
+ logger.debug(
316
+ "Normalizing timestamp for postgresql from %s to %s",
317
+ input,
318
+ normalized,
319
+ )
286
320
  return float(normalized)
287
321
  elif len(input) == 27:
288
322
  obj_from_iso = convert_iso_string_to_datetime_obj(input)
289
- unix_with_subseconds = get_timestamp_unix_subseconds_decimal(obj_from_iso)
323
+ unix_with_subseconds = get_timestamp_unix_subseconds_decimal(
324
+ obj_from_iso
325
+ )
290
326
  normalized = str(unix_with_subseconds)[:14]
291
- logger.debug("Normalizing timestamp for postgresql from %s to %s", input, normalized)
327
+ logger.debug(
328
+ "Normalizing timestamp for postgresql from %s to %s",
329
+ input,
330
+ normalized,
331
+ )
292
332
  return float(normalized)
293
333
  else:
294
334
  logger.error("Unexcpected timestamp format")
295
335
  except Exception as msg:
296
- logger.exception(msg)
336
+ logger.exception(msg)
@@ -0,0 +1,64 @@
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,6 +1,5 @@
1
- import logging
2
1
  from datetime import datetime, timezone
3
- import src.time_fuctions_cornebester.time_functions as time_functions
2
+ import src.time_functions.time_functions as time_functions
4
3
 
5
4
 
6
5
  new_obj = datetime.now(timezone.utc)
@@ -24,33 +23,53 @@ obj_from_unix_seconds = time_functions.convert_unix_to_datetime_obj(unix)
24
23
  obj_from_unix_milliseconds = time_functions.convert_unix_to_datetime_obj(unix_millis)
25
24
  obj_from_unix_microseconds = time_functions.convert_unix_to_datetime_obj(unix_micros)
26
25
 
27
- obj_from_unix_seconds_float_millis = time_functions.convert_unix_to_datetime_obj(unix_millis/1000)
28
- obj_from_unix_seconds_float_micros = time_functions.convert_unix_to_datetime_obj(unix_micros/1000000)
29
- obj_from_unix_seconds_float = time_functions.convert_unix_to_datetime_obj(unix_with_subseconds)
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
+ )
30
35
 
31
36
 
32
37
  def test_convertions_from_sample():
33
- assert time_functions.convert_unix_to_datetime_obj(1742736574) == time_functions.convert_iso_string_to_datetime_obj("2025-03-23T13:29:34+00:00")
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")
34
41
 
35
42
 
36
43
  def test_convertions_from_sample2():
37
- assert time_functions.convert_unix_to_datetime_obj(1742737159020) == time_functions.convert_iso_string_to_datetime_obj("2025-03-23T13:39:19.020Z")
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")
38
47
 
39
48
 
40
49
  def test_convertions_from_sample3():
41
- assert time_functions.convert_unix_to_datetime_obj(1742737771434946) == time_functions.convert_iso_string_to_datetime_obj("2025-03-23T13:49:31.434946Z")
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
+ )
42
55
 
43
56
 
44
57
  def test_convertions_from_sample4():
45
- assert time_functions.convert_unix_to_datetime_obj(unix) == time_functions.convert_iso_string_to_datetime_obj(iso)
58
+ assert time_functions.convert_unix_to_datetime_obj(
59
+ unix
60
+ ) == time_functions.convert_iso_string_to_datetime_obj(iso)
46
61
 
47
62
 
48
63
  def test_convertions_from_sample5():
49
- assert time_functions.convert_unix_to_datetime_obj(unix_millis) == time_functions.convert_iso_string_to_datetime_obj(iso_millis)
64
+ assert time_functions.convert_unix_to_datetime_obj(
65
+ unix_millis
66
+ ) == time_functions.convert_iso_string_to_datetime_obj(iso_millis)
50
67
 
51
68
 
52
69
  def test_convertions_from_sample6():
53
- assert time_functions.convert_unix_to_datetime_obj(unix_micros) == time_functions.convert_iso_string_to_datetime_obj(iso_micros)
70
+ assert time_functions.convert_unix_to_datetime_obj(
71
+ unix_micros
72
+ ) == time_functions.convert_iso_string_to_datetime_obj(iso_micros)
54
73
 
55
74
 
56
75
  def test_convertions_from_sample7():
@@ -78,34 +97,45 @@ def test_convertions_from_sample12():
78
97
 
79
98
 
80
99
  def test_convertions_from_sample13():
81
- assert time_functions.convert_unix_to_datetime_obj(unix_with_subseconds) == time_functions.convert_iso_string_to_datetime_obj(iso_micros)
100
+ assert time_functions.convert_unix_to_datetime_obj(
101
+ unix_with_subseconds
102
+ ) == time_functions.convert_iso_string_to_datetime_obj(iso_micros)
82
103
 
83
104
 
84
105
  def test_convertions_from_sample14():
85
- '''
106
+ """
86
107
  # obj_from_iso = time_functions.convert_iso_string_to_datetime_obj("2025-03-23T15:10:25Z")
87
108
  # unix_with_subseconds = int(time_functions.get_timestamp_unix_subseconds_decimal(obj_from_iso))
88
109
  # unix_with_subseconds == 1742742625
89
- '''
90
- assert time_functions.timestamp_parser_psql_millis("2025-03-23T15:10:25Z") == 1742742625
110
+ """
111
+ assert (
112
+ time_functions.timestamp_parser_psql_millis("2025-03-23T15:10:25Z")
113
+ == 1742742625
114
+ )
91
115
 
92
116
 
93
117
  def test_convertions_from_sample15():
94
- '''
118
+ """
95
119
  # obj_from_iso = time_functions.convert_iso_string_to_datetime_obj("2025-03-23T15:10:25.002Z")
96
120
  # unix_with_subseconds = time_functions.get_timestamp_unix_subseconds_decimal(obj_from_iso)
97
121
  # unix_with_subseconds == 1742742625.002
98
- '''
99
- assert time_functions.timestamp_parser_psql_millis("2025-03-23T15:10:25.002Z") == 1742742625.002
122
+ """
123
+ assert (
124
+ time_functions.timestamp_parser_psql_millis("2025-03-23T15:10:25.002Z")
125
+ == 1742742625.002
126
+ )
100
127
 
101
128
 
102
129
  def test_convertions_from_sample16():
103
- '''
130
+ """
104
131
  # obj_from_iso = time_functions.convert_iso_string_to_datetime_obj("2025-03-23T15:10:25.002908Z")
105
132
  # unix_with_subseconds = time_functions.get_timestamp_unix_subseconds_decimal(obj_from_iso)
106
133
  # unix_with_subseconds == 1742742625.002908
107
- '''
108
- assert time_functions.timestamp_parser_psql_millis("2025-03-23T15:10:25.002908Z") == 1742742625.002
134
+ """
135
+ assert (
136
+ time_functions.timestamp_parser_psql_millis("2025-03-23T15:10:25.002908Z")
137
+ == 1742742625.002
138
+ )
109
139
 
110
140
 
111
141
  def test_convertions_from_sample17():
@@ -113,68 +143,77 @@ def test_convertions_from_sample17():
113
143
 
114
144
 
115
145
  def test_convertions_from_sample18():
116
- '''
146
+ """
117
147
  postgresql timeformat
118
- '''
148
+ """
119
149
  assert time_functions.timestamp_parser_psql_millis(1742742625.0) == 1742742625.0
120
150
 
121
151
 
122
152
  def test_convertions_from_sample19():
123
- '''
153
+ """
124
154
  postgresql timeformat
125
- '''
155
+ """
126
156
  assert time_functions.timestamp_parser_psql_millis(1742742625.002) == 1742742625.002
127
157
 
128
158
 
129
159
  def test_convertions_from_sample20():
130
- '''
160
+ """
131
161
  postgresql timeformat
132
- '''
133
- assert time_functions.timestamp_parser_psql_millis(1742742625.002908) == 1742742625.002
162
+ """
163
+ assert (
164
+ time_functions.timestamp_parser_psql_millis(1742742625.002908) == 1742742625.002
165
+ )
134
166
 
135
167
 
136
168
  def test_convertions_from_sample21():
137
- '''
169
+ """
138
170
  python millis timeformat
139
- '''
171
+ """
140
172
  assert time_functions.timestamp_parser_psql_millis(1742742625002) == 1742742625.002
141
173
 
142
174
 
143
175
  def test_convertions_from_sample22():
144
- '''
176
+ """
145
177
  python micros timeformat
146
- '''
147
- assert time_functions.timestamp_parser_psql_millis(1742742625002908) == 1742742625.002
178
+ """
179
+ assert (
180
+ time_functions.timestamp_parser_psql_millis(1742742625002908) == 1742742625.002
181
+ )
182
+
148
183
 
149
184
  def test_convertions_from_sample33():
150
- '''
185
+ """
151
186
  postgresql nano timeformat
152
- '''
153
- assert time_functions.timestamp_parser_psql_millis(1742742625.002908123) == 1742742625.002
187
+ """
188
+ assert (
189
+ time_functions.timestamp_parser_psql_millis(1742742625.002908123)
190
+ == 1742742625.002
191
+ )
154
192
 
155
193
 
156
194
  def test_convertions_from_sample32():
157
- '''
195
+ """
158
196
  bad timeformat
159
- '''
197
+ """
160
198
  assert time_functions.timestamp_parser_psql_millis(1742742625002.908) is None
161
199
 
162
200
 
163
201
  def test_convertions_from_sample34():
164
- '''
202
+ """
165
203
  bad timeformat
166
- '''
204
+ """
167
205
  assert time_functions.timestamp_sanitizer_psql(1729755232184) == 1729755232.184
168
206
 
207
+
169
208
  def test_convertions_from_sample35():
170
- '''
209
+ """
171
210
  bad timeformat
172
- '''
211
+ """
173
212
  assert time_functions.timestamp_sanitizer_psql(1729765227856.3) == 1729765227.856
174
213
 
175
214
 
176
215
  def test_convertions_from_sample36():
177
- '''
216
+ """
178
217
  bad timeformat
179
- '''
180
- assert time_functions.timestamp_sanitizer_psql(1729765228327.051) == 1729765228.327
218
+ """
219
+ assert time_functions.timestamp_sanitizer_psql(1729765228327.051) == 1729765228.327
@@ -1,8 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: python_time_functions
3
- Version: 2.1.1
4
- Summary: Common Python functions for time handling
5
- Author-email: Corne Bester <corne.bester@gmail.com>
6
- License-Expression: MIT
7
- License-File: LICENSE
8
- Dynamic: license-file
@@ -1,46 +0,0 @@
1
- # python_time_functions
2
-
3
- example
4
-
5
- ```
6
- from datetime import datetime, timezone
7
- from modules.time_functions import get_timestamp_unix_millis
8
- # OR
9
- from time_functions import get_timestamp_unix_millis
10
- # OR
11
- import time_functions
12
-
13
- timestamp = datetime.now(timezone.utc)
14
- unix_millis = get_timestamp_unix_millis(timestamp) # create unix timestamp from obj above
15
-
16
- ```
17
-
18
- ## local dev
19
-
20
- pip install pytest build
21
-
22
- ## test
23
-
24
- pytest
25
-
26
- ## build ( create dist artifacts )
27
-
28
- python -m build
29
-
30
- ## install from location
31
-
32
- python -m pip install "C:\Users\corne\Documents\GitHub\python_time_functions\dist\pythom_time_functions-2.1.0-py3-none-any.whl"
33
-
34
-
35
- ### other
36
-
37
- pip3 freeze > requirements.txt
38
-
39
- ## bad formats I dreamed up for iot/psql. fix with sanitizer fx
40
-
41
- >>> time_functions.timestamp_sanitizer_psql(1729755232184)
42
- 1729755232.184
43
- >>> time_functions.timestamp_sanitizer_psql(1729765227856.3)
44
- 1729765227.856
45
- >>> time_functions.timestamp_sanitizer_psql(1729765228327.051)
46
- 1729765228.327
@@ -1,14 +0,0 @@
1
- [build-system]
2
- requires = ["setuptools>=65.5.0"]
3
- build-backend = "setuptools.build_meta"
4
-
5
- [project]
6
- name = "python_time_functions"
7
- version = "2.1.1"
8
- description = "Common Python functions for time handling"
9
- authors = [{name = "Corne Bester", email = "corne.bester@gmail.com"}]
10
- dependencies = [
11
- ]
12
-
13
- license = "MIT"
14
- license-files = ["LICEN[CS]E*"]
@@ -1,8 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: python_time_functions
3
- Version: 2.1.1
4
- Summary: Common Python functions for time handling
5
- Author-email: Corne Bester <corne.bester@gmail.com>
6
- License-Expression: MIT
7
- License-File: LICENSE
8
- Dynamic: license-file
@@ -1 +0,0 @@
1
- time_fuctions_cornebester
@@ -1,64 +0,0 @@
1
- import src.time_fuctions_cornebester.time_functions as time_functions
2
-
3
- def test_convertions_from_sample23():
4
- assert float(time_functions.timestamp_sanitizer_psql(1742758997)) == 1742758997
5
-
6
-
7
- def test_convertions_from_sample24():
8
- '''
9
- # unix seconds
10
- '''
11
- assert int(time_functions.timestamp_sanitizer_psql(1742758997)) == 1742758997
12
-
13
-
14
- def test_convertions_from_sample25():
15
- '''
16
- # unix millis
17
- '''
18
- assert float(time_functions.timestamp_sanitizer_psql(1742758997018)) == 1742758997.018
19
-
20
-
21
- def test_convertions_from_sample26():
22
- '''
23
- # unix micros
24
- '''
25
- assert float(time_functions.timestamp_sanitizer_psql(1742758997018308)) == 1742758997.018
26
-
27
-
28
- def test_convertions_from_sample27():
29
- '''
30
- # unix micros
31
- '''
32
- assert float(time_functions.timestamp_sanitizer_psql(1742758997018308)) == 1742758997.018
33
-
34
-
35
- def test_convertions_from_sample28():
36
- '''
37
- # psql special
38
- '''
39
- assert float(time_functions.timestamp_sanitizer_psql(1742758997.018308)) == 1742758997.018
40
-
41
-
42
- def test_convertions_from_sample29():
43
- '''
44
- # psql special
45
- '''
46
- assert float(time_functions.timestamp_sanitizer_psql(1742758997.018)) == 1742758997.018
47
-
48
-
49
- def test_convertions_from_sample30():
50
- '''
51
- # bad format
52
- '''
53
- assert float(time_functions.timestamp_sanitizer_psql(1742758997018.308)) == 1742758997.018
54
-
55
-
56
- def test_convertions_from_sample31():
57
- '''
58
- # bad format
59
- '''
60
- assert float(time_functions.timestamp_sanitizer_psql("2025-03-23T19:43:17.018Z")) == 1742758997.018
61
-
62
-
63
- def test_convertions_from_sample32():
64
- assert time_functions.timestamp_sanitizer_psql(1742742625002.908) == 1742742625.002