Skip to content

Commit

Permalink
fix gcp strptime
Browse files Browse the repository at this point in the history
  • Loading branch information
maskarb committed Aug 30, 2023
1 parent 5f39ae1 commit 1b49868
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions nise/generators/gcp/cloud_storage_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions nise/generators/gcp/compute_engine_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions nise/generators/gcp/gcp_database_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions nise/generators/gcp/gcp_network_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 1b49868

Please sign in to comment.