Skip to content

Commit

Permalink
Merge pull request #433 from carbonblack/fix-fromisoformat
Browse files Browse the repository at this point in the history
Fix fromisoformat
  • Loading branch information
avanbrunt-cb committed Oct 24, 2023
2 parents af328a4 + 5e0cdb1 commit 2915360
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 100 deletions.
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ validators
jsonschema
keyring;platform_system=='Darwin'
boto3
backports-datetime-fromisoformat==2.0.1


# Dev dependencies
pytest==7.2.1
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
'validators',
'jsonschema',
"keyring;platform_system=='Darwin'",
'boto3'
'boto3',
'backports-datetime-fromisoformat==2.0.1'
]

extras_require = {
Expand Down
6 changes: 4 additions & 2 deletions src/cbc_sdk/platform/alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
from cbc_sdk.platform.legacy_alerts import LegacyAlertSearchQueryCriterionMixin
from cbc_sdk.platform.jobs import Job

from backports._datetime_fromisoformat import datetime_fromisoformat

"""Alert Models"""

MAX_RESULTS_LIMIT = 10000
Expand Down Expand Up @@ -1127,9 +1129,9 @@ def _create_valid_time_filter(self, kwargs):
etime = kwargs["end"]
try:
if isinstance(stime, str):
stime = datetime.datetime.fromisoformat(stime)
stime = datetime_fromisoformat(stime)
if isinstance(etime, str):
etime = datetime.datetime.fromisoformat(etime)
etime = datetime_fromisoformat(etime)
if isinstance(stime, datetime.datetime) and isinstance(etime, datetime.datetime):
time_filter = {"start": stime.strftime("%Y-%m-%dT%H:%M:%S.%fZ"),
"end": etime.strftime("%Y-%m-%dT%H:%M:%S.%fZ")}
Expand Down
Loading

0 comments on commit 2915360

Please sign in to comment.