From 1b4986886455f3370a36e2b950231578c9d8c762 Mon Sep 17 00:00:00 2001 From: maskarb Date: Wed, 30 Aug 2023 16:06:59 -0400 Subject: [PATCH] fix gcp strptime --- nise/generators/gcp/cloud_storage_generator.py | 6 +++--- nise/generators/gcp/compute_engine_generator.py | 6 +++--- nise/generators/gcp/gcp_database_generator.py | 6 +++--- nise/generators/gcp/gcp_network_generator.py | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/nise/generators/gcp/cloud_storage_generator.py b/nise/generators/gcp/cloud_storage_generator.py index c651be3b..ef14052e 100644 --- a/nise/generators/gcp/cloud_storage_generator.py +++ b/nise/generators/gcp/cloud_storage_generator.py @@ -85,7 +85,7 @@ def _update_data(self, row): # noqa: C901 credit, credit_total = self._gen_credit(self.credit_total, self._credit_amount) self.credit_total = credit_total row["credits"] = credit - usage_date = datetime.strptime(row.get("usage_start_time"), "%Y-%m-%dT%H:%M:%S") + usage_date = datetime.strptime(row.get("usage_start_time"), "%Y-%m-%dT%H:%M:%S%z") row["invoice.month"] = f"{usage_date.year}{usage_date.month:02d}" if self.attributes: @@ -151,8 +151,8 @@ def _update_data(self, row): # noqa: C901 row["cost_type"] = "regular" row["currency_conversion_rate"] = 1 invoice = {} - year = datetime.strptime(row.get("usage_start_time"), "%Y-%m-%dT%H:%M:%S").year - month = datetime.strptime(row.get("usage_start_time"), "%Y-%m-%dT%H:%M:%S").month + year = datetime.strptime(row.get("usage_start_time"), "%Y-%m-%dT%H:%M:%S%z").year + month = datetime.strptime(row.get("usage_start_time"), "%Y-%m-%dT%H:%M:%S%z").month invoice["month"] = f"{year}{month:02d}" row["invoice"] = invoice if self.resource_level: diff --git a/nise/generators/gcp/compute_engine_generator.py b/nise/generators/gcp/compute_engine_generator.py index dc6d447c..1f2da63a 100644 --- a/nise/generators/gcp/compute_engine_generator.py +++ b/nise/generators/gcp/compute_engine_generator.py @@ -103,7 +103,7 @@ def _update_data(self, row): # noqa: C901 credit, credit_total = self._gen_credit(self.credit_total, self._credit_amount) self.credit_total = credit_total row["credits"] = credit - usage_date = datetime.strptime(row.get("usage_start_time"), "%Y-%m-%dT%H:%M:%S") + usage_date = datetime.strptime(row.get("usage_start_time"), "%Y-%m-%dT%H:%M:%S%z") row["invoice.month"] = f"{usage_date.year}{usage_date.month:02d}" if self.attributes: @@ -170,8 +170,8 @@ def _update_data(self, row): # noqa: C901 row["cost_type"] = "regular" row["currency_conversion_rate"] = 1 invoice = {} - year = datetime.strptime(row.get("usage_start_time"), "%Y-%m-%dT%H:%M:%S").year - month = datetime.strptime(row.get("usage_start_time"), "%Y-%m-%dT%H:%M:%S").month + year = datetime.strptime(row.get("usage_start_time"), "%Y-%m-%dT%H:%M:%S%z").year + month = datetime.strptime(row.get("usage_start_time"), "%Y-%m-%dT%H:%M:%S%z").month invoice["month"] = f"{year}{month:02d}" row["invoice"] = invoice if self.resource_level: diff --git a/nise/generators/gcp/gcp_database_generator.py b/nise/generators/gcp/gcp_database_generator.py index fd5ac4f0..e7ba765b 100644 --- a/nise/generators/gcp/gcp_database_generator.py +++ b/nise/generators/gcp/gcp_database_generator.py @@ -90,7 +90,7 @@ def _update_data(self, row): # noqa: C901 credit, credit_total = self._gen_credit(self.credit_total, self._credit_amount) self.credit_total = credit_total row["credits"] = credit - usage_date = datetime.strptime(row.get("usage_start_time"), "%Y-%m-%dT%H:%M:%S") + usage_date = datetime.strptime(row.get("usage_start_time"), "%Y-%m-%dT%H:%M:%S%z") row["invoice.month"] = f"{usage_date.year}{usage_date.month:02d}" if self.attributes: @@ -157,9 +157,9 @@ def _update_data(self, row): # noqa: C901 credit, credit_total = self._gen_credit(self.credit_total, self._credit_amount, True) self.credit_total = credit_total row["credits"] = credit - usage_date = datetime.strptime(row.get("usage_start_time"), "%Y-%m-%dT%H:%M:%S") + usage_date = datetime.strptime(row.get("usage_start_time"), "%Y-%m-%dT%H:%M:%S%z") invoice = {} - usage_date = datetime.strptime(row.get("usage_start_time"), "%Y-%m-%dT%H:%M:%S") + usage_date = datetime.strptime(row.get("usage_start_time"), "%Y-%m-%dT%H:%M:%S%z") invoice["month"] = f"{usage_date.year}{usage_date.month:02d}" row["invoice"] = invoice if self.resource_level: diff --git a/nise/generators/gcp/gcp_network_generator.py b/nise/generators/gcp/gcp_network_generator.py index f17d0e2f..0cf2b573 100644 --- a/nise/generators/gcp/gcp_network_generator.py +++ b/nise/generators/gcp/gcp_network_generator.py @@ -96,7 +96,7 @@ def _update_data(self, row): # noqa: C901 credit, credit_total = self._gen_credit(self.credit_total, self._credit_amount) self.credit_total = credit_total row["credits"] = credit - usage_date = datetime.strptime(row.get("usage_start_time"), "%Y-%m-%dT%H:%M:%S") + usage_date = datetime.strptime(row.get("usage_start_time"), "%Y-%m-%dT%H:%M:%S%z") row["invoice.month"] = f"{usage_date.year}{usage_date.month:02d}" if self.attributes: @@ -162,9 +162,9 @@ def _update_data(self, row): # noqa: C901 credit, credit_total = self._gen_credit(self.credit_total, self._credit_amount, True) self.credit_total = credit_total row["credits"] = credit - usage_date = datetime.strptime(row.get("usage_start_time"), "%Y-%m-%dT%H:%M:%S") + usage_date = datetime.strptime(row.get("usage_start_time"), "%Y-%m-%dT%H:%M:%S%z") invoice = {} - usage_date = datetime.strptime(row.get("usage_start_time"), "%Y-%m-%dT%H:%M:%S") + usage_date = datetime.strptime(row.get("usage_start_time"), "%Y-%m-%dT%H:%M:%S%z") invoice["month"] = f"{usage_date.year}{usage_date.month:02d}" row["invoice"] = invoice if self.resource_level: