Skip to content
This repository has been archived by the owner on Jun 17, 2023. It is now read-only.

Commit

Permalink
Fix int error (#144)
Browse files Browse the repository at this point in the history
Handle cases where parse_timestamp is passed an int. func now handles datetime, int, float, str types in the following formats (with specific examples):

- 'YYYY-MM-DD HH:mm:ss': '2020-08-20 21:32:51'
- 'YYYY-MM-DD HH:mm:ss UTC': '2020-08-20 21:32:51 UTC'
- 'YYYYMMDD': '20200820', int(20200820)
- epoch (with and without milliseconds decimal): int(1590673128), float(1590673128), float(1590673128.02), str(1590673128.02),
	str(1590673128)
- 'YYYY-MM-DDTHH:mm:ss': '2020-08-20T21:32:51'
- 'YYYYMMDDTHHmmssZ': '20160219T224322Z'
  • Loading branch information
mdavis332 authored Sep 16, 2020
1 parent 53d3c41 commit 6b2c6c0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion csirtg_indicator/utils/ztime.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ def parse_timestamp(ts):
if t:
return t

ts_len = len(ts)
ts_len = 0
if isinstance(ts, str):
ts_len = len(ts)
elif isinstance(ts, int):
ts_len = len(str(ts))

try:
t = arrow.get(ts)
Expand Down

0 comments on commit 6b2c6c0

Please sign in to comment.