From 0aa7d84d0df7d6e20ddd99e7a8b3403d897d2acb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matth=C3=A4us=20Wander?= Date: Sun, 6 Jun 2021 18:41:23 +0200 Subject: [PATCH] Use UTC datetimes for Elastic. Elastic by default expects UTC. --- parsedmarc/elastic.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/parsedmarc/elastic.py b/parsedmarc/elastic.py index d6c3ae0..4eb64f0 100644 --- a/parsedmarc/elastic.py +++ b/parsedmarc/elastic.py @@ -301,10 +301,10 @@ def save_aggregate_report_to_elasticsearch(aggregate_report, org_name = metadata["org_name"] report_id = metadata["report_id"] domain = aggregate_report["policy_published"]["domain"] - begin_date = human_timestamp_to_datetime(metadata["begin_date"]) - end_date = human_timestamp_to_datetime(metadata["end_date"]) - begin_date_human = begin_date.strftime("%Y-%m-%d %H:%M:%S") - end_date_human = end_date.strftime("%Y-%m-%d %H:%M:%S") + begin_date = human_timestamp_to_datetime(metadata["begin_date"], to_utc=True) + end_date = human_timestamp_to_datetime(metadata["end_date"], to_utc=True) + begin_date_human = begin_date.strftime("%Y-%m-%d %H:%M:%SZ") + end_date_human = end_date.strftime("%Y-%m-%d %H:%M:%SZ") if monthly_indexes: index_date = begin_date.strftime("%Y-%m") else: