Skip to content

Commit

Permalink
fix: Solve timezone issue in ActivityAuditClientV1 (#206)
Browse files Browse the repository at this point in the history
* Use now instead of utcnow()
* Fix also example
* Fix also test
  • Loading branch information
alblasco authored May 4, 2022
1 parent 47b14d7 commit 2242929
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions sdcclient/secure/_activity_audit_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def list_events(self, from_date=None, to_date=None, scope_filter=None, limit=0,
Examples:
>>> client = ActivityAuditClientV1(token=SECURE_TOKEN)
>>>
>>> now = datetime.datetime.utcnow()
>>> now = datetime.datetime.now()
>>> three_days_ago = now - datetime.timedelta(days=3)
>>> max_event_number_retrieved = 50
>>> data_sources = [ActivityAuditDataSource.CMD, ActivityAuditDataSource.KUBE_EXEC]
Expand All @@ -49,9 +49,9 @@ def list_events(self, from_date=None, to_date=None, scope_filter=None, limit=0,
number_of_events_per_query = 50

if from_date is None:
from_date = datetime.datetime.utcnow() - datetime.timedelta(days=1)
from_date = datetime.datetime.now() - datetime.timedelta(days=1)
if to_date is None:
to_date = datetime.datetime.utcnow()
to_date = datetime.datetime.now()

filters = scope_filter if scope_filter else []
if data_sources:
Expand Down
2 changes: 1 addition & 1 deletion specs/secure/activitylog_v1_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

with context("when listing the events from the last 3 days"):
with it("retrieves all the events"):
three_days_ago = datetime.datetime.utcnow() - datetime.timedelta(days=3)
three_days_ago = datetime.datetime.now() - datetime.timedelta(days=3)
ok, res = self.client.list_events(from_date=three_days_ago)

expect((ok, res)).to(be_successful_api_call)
Expand Down

0 comments on commit 2242929

Please sign in to comment.