File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ {
2+ "snyk.advanced.organization" : " 4d30615c-6bb3-4e73-9c86-2fce0ad942d2" ,
3+ "snyk.advanced.autoSelectOrganization" : true
4+ }
Original file line number Diff line number Diff line change 44
55```
66from datetime import datetime, timezone
7- from modules.time_functions import get_timestamp_unix_millis
8- # OR
97from time_functions import get_timestamp_unix_millis
108# OR
119import time_functions
@@ -17,30 +15,16 @@ unix_millis = get_timestamp_unix_millis(timestamp) # create unix timestamp from
1715
1816## local dev
1917
20- pip install pytest build
18+ pip install -r requirements.txt
19+
2120
2221## test
2322
2423 pytest
2524
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-
3425
3526### other
3627
3728 pip3 freeze > requirements.txt
3829
39- ## bad formats I dreamed up for iot/psql. fix with sanitizer fx
4030
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
Original file line number Diff line number Diff line change 11import logging
22
33from datetime import datetime , timezone
4- import time_functions
4+ import src . python_time_fuctions . time_functions as time_functions
55
66logger = logging .getLogger (__name__ )
77
4141print (f"unix_micros: { unix_micros } " )
4242print (f"unix_with_subseconds: { unix_with_subseconds } " )
4343
44- print ("--- convertions ---" )
44+ print ("--- conversions ---" )
4545print (f"obj_from_iso: { obj_from_iso } " , )
4646print (f"obj_from_iso_millis: { obj_from_iso_millis } " )
4747print (f"obj_from_iso_micros: { obj_from_iso_micros } " )
5959dtstmp = (
6060 obj .strftime ("%Y%m%d-%H%M%S.%f" )[:- 3 ] + " UTC,"
6161) # Chris format for psql
62- print (f"CSIRO : { dtstmp } " )
62+ print (f"custom : { dtstmp } " )
Original file line number Diff line number Diff line change @@ -3,12 +3,22 @@ requires = ["setuptools>=65.5.0"]
33build-backend = " setuptools.build_meta"
44
55[project ]
6- name = " pythom_time_functions "
7- version = " 2.1.1 "
6+ name = " python_time_functions "
7+ version = " 2.1.2 "
88description = " Common Python functions for time handling"
9+ readme = " README.md"
910authors = [{name = " Corne Bester" , email = " corne.bester@gmail.com" }]
1011dependencies = [
12+ " datetime" ,
13+ " timezone"
1114]
12-
1315license = " MIT"
14- license-files = [" LICEN[CS]E*" ]
16+ license-files = [" LICEN[CS]E*" ]
17+
18+ [project .urls ]
19+ Homepage = " https://example.com"
20+ Documentation = " https://readthedocs.org"
21+ Repository = " https://github.com/cornebester/python_time_functions"
22+ Issues = " https://github.com/cornebester/python_time_functions/issues"
23+ Changelog = " https://github.com/cornebester/python_time_functions/blob/master/CHANGELOG.md"
24+
Original file line number Diff line number Diff line change 1- build == 1.3.0
1+ backports.tarfile == 1.2.0
2+ build == 1.4.0
3+ certifi == 2026.2.25
4+ charset-normalizer == 3.4.5
25colorama == 0.4.6
3- exceptiongroup == 1.3.0
6+ docutils == 0.22.4
7+ exceptiongroup == 1.3.1
8+ id == 1.6.1
9+ idna == 3.11
10+ importlib_metadata == 8.7.1
411iniconfig == 2.3.0
5- packaging == 25.0
12+ jaraco.classes == 3.4.0
13+ jaraco.context == 6.1.1
14+ jaraco.functools == 4.4.0
15+ keyring == 25.7.0
16+ markdown-it-py == 4.0.0
17+ mdurl == 0.1.2
18+ more-itertools == 10.8.0
19+ nh3 == 0.3.3
20+ packaging == 26.0
621pluggy == 1.6.0
722Pygments == 2.19.2
823pyproject_hooks == 1.2.0
9- pytest == 8.4.2
10- tomli == 2.3.0
11- typing_extensions == 4.15.0
24+ pytest == 9.0.2
25+ pywin32-ctypes == 0.2.3
26+ readme_renderer == 44.0
27+ requests == 2.32.5
28+ requests-toolbelt == 1.0.0
29+ rfc3986 == 2.0.0
30+ rich == 14.3.3
31+ tomli == 2.4.0
32+ twine == 6.2.0
33+ typing_extensions == 4.15.0
34+ urllib3 == 2.6.3
35+ zipp == 3.23.0
Original file line number Diff line number Diff line change @@ -241,8 +241,14 @@ def timestamp_parser_psql_millis(timestamp):
241241def timestamp_sanitizer_psql (input ):
242242 '''
243243 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:
246252 unix micros or millis in decimal format
247253 unix millis or micros in unix format
248254 iso8601
Original file line number Diff line number Diff line change 1- import time_functions
1+ import src . python_time_fuctions . time_functions as time_functions
22
33def test_convertions_from_sample23 ():
44 assert float (time_functions .timestamp_sanitizer_psql (1742758997 )) == 1742758997
Original file line number Diff line number Diff line change 11import logging
22from datetime import datetime , timezone
3- import time_functions
3+ import src . python_time_fuctions . time_functions as time_functions
44
55
66new_obj = datetime .now (timezone .utc )
You can’t perform that action at this time.
0 commit comments