python-time-functions 2.1.2__py3-none-any.whl → 2.1.3__py3-none-any.whl

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.
@@ -1,9 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python_time_functions
3
- Version: 2.1.2
3
+ Version: 2.1.3
4
4
  Summary: Common Python functions for time handling
5
5
  Author-email: Corne Bester <corne.bester@gmail.com>
6
- License-Expression: MIT
7
6
  Project-URL: Homepage, https://example.com
8
7
  Project-URL: Documentation, https://readthedocs.org
9
8
  Project-URL: Repository, https://github.com/cornebester/python_time_functions
@@ -15,15 +14,16 @@ Requires-Dist: datetime
15
14
  Requires-Dist: timezone
16
15
  Dynamic: license-file
17
16
 
18
- # python_time_functions
17
+ # Readme
19
18
 
20
- example
19
+ Common Python functions for time handling
21
20
 
22
- ```
21
+ ```python
23
22
  from datetime import datetime, timezone
24
- from time_functions import get_timestamp_unix_millis
25
- # OR
23
+
26
24
  import time_functions
25
+ # OR
26
+ from time_functions import get_timestamp_unix_millis
27
27
 
28
28
  timestamp = datetime.now(timezone.utc)
29
29
  unix_millis = get_timestamp_unix_millis(timestamp) # create unix timestamp from obj above
@@ -0,0 +1,7 @@
1
+ python_time_functions-2.1.3.dist-info/licenses/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
2
+ time_functions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ time_functions/time_functions.py,sha256=i6ZJkdyvXf-iZiQPLnRtJaWybBY704dx4uKQ82_17_g,14106
4
+ python_time_functions-2.1.3.dist-info/METADATA,sha256=OSLL9Qwt8rtDuyLg2rAkAdEkt1fByHn6QUp1BQtbzd8,1148
5
+ python_time_functions-2.1.3.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
6
+ python_time_functions-2.1.3.dist-info/top_level.txt,sha256=EEztmW3tTQHD5ZxrHagnKcjGTYwWiIn-QLJiPTIHPGc,15
7
+ python_time_functions-2.1.3.dist-info/RECORD,,
@@ -0,0 +1 @@
1
+ time_functions
@@ -239,7 +239,7 @@ 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
244
  Attemps to fix/sanitize bad timestamp format I dreamed up like
245
245
  >>> time_functions.timestamp_sanitizer_psql(1729755232184)
@@ -250,53 +250,87 @@ def timestamp_sanitizer_psql(input):
250
250
  1729765228.327
251
251
  handle timestamp as:
252
252
  unix micros or millis in decimal format
253
- unix millis or micros in unix format
253
+ unix millis or micros in unix format
254
254
  iso8601
255
- '''
255
+ """
256
256
  try:
257
257
  if isinstance(input, int):
258
258
  if len(str(input)) == 10:
259
259
  logger.debug("Not millsecond precision: %s", input)
260
260
  return input
261
261
  elif len(str(input)) == 13:
262
- normalized = str((input/1000))[:14]
263
- 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
+ )
264
268
  return float(normalized)
265
269
  elif len(str(input)) == 16:
266
- normalized = str(input/1000000)[:14]
267
- 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
+ )
268
276
  return float(normalized)
269
277
  elif isinstance(input, float):
270
278
  # elif '.' in str(input):
271
- decimal_index = str.index(str(input), '.')
279
+ decimal_index = str.index(str(input), ".")
272
280
  if decimal_index == 13:
273
- normalized = str(input/1000)[:14] # remove microsecond precision
274
- 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
+ )
275
287
  return float(normalized)
276
288
  elif decimal_index == 10:
277
289
  normalized = str(input)[:14] # remove microsecond precision
278
- 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
+ )
279
295
  return float(normalized)
280
296
  elif isinstance(input, str):
281
297
  if len(input) == 20:
282
298
  obj_from_iso = convert_iso_string_to_datetime_obj(input)
283
- 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
+ )
284
302
  normalized = unix_with_subseconds
285
- 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
+ )
286
308
  return float(normalized)
287
309
  if len(input) == 24:
288
310
  obj_from_iso = convert_iso_string_to_datetime_obj(input)
289
- 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
+ )
290
314
  normalized = unix_with_subseconds
291
- 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
+ )
292
320
  return float(normalized)
293
321
  elif len(input) == 27:
294
322
  obj_from_iso = convert_iso_string_to_datetime_obj(input)
295
- 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
+ )
296
326
  normalized = str(unix_with_subseconds)[:14]
297
- 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
+ )
298
332
  return float(normalized)
299
333
  else:
300
334
  logger.error("Unexcpected timestamp format")
301
335
  except Exception as msg:
302
- logger.exception(msg)
336
+ logger.exception(msg)
@@ -1,7 +0,0 @@
1
- python_time_fuctions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- python_time_fuctions/time_functions.py,sha256=pYx-9DkAMTN7lPZFpADSPS3rYoCTyN9WTeNEOJ7ZYuM,13398
3
- python_time_functions-2.1.2.dist-info/licenses/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
4
- python_time_functions-2.1.2.dist-info/METADATA,sha256=-eDdb7vQpUgCJSRSU1dwwlAG1PRgfCRbqT76KxOx53k,1146
5
- python_time_functions-2.1.2.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
6
- python_time_functions-2.1.2.dist-info/top_level.txt,sha256=3d_kzH6xTbKIDrsbvDIy9vJwDrKmVr8Y6cE79YOwi54,21
7
- python_time_functions-2.1.2.dist-info/RECORD,,
@@ -1 +0,0 @@
1
- python_time_fuctions
File without changes