From a70a48657c21d820094df25399cfc8a62cc09a71 Mon Sep 17 00:00:00 2001 From: Geoff Munn Date: Tue, 11 Apr 2023 20:58:05 +1200 Subject: [PATCH] Date format fixed --- terra_sdk/core/staking/data/delegation.py | 6 +++++- terra_sdk/core/staking/data/validator.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/terra_sdk/core/staking/data/delegation.py b/terra_sdk/core/staking/data/delegation.py index bc27ce8..63fd297 100644 --- a/terra_sdk/core/staking/data/delegation.py +++ b/terra_sdk/core/staking/data/delegation.py @@ -111,11 +111,15 @@ def to_data(self) -> dict: @classmethod def from_data(cls, data: dict) -> UnbondingDelegationEntry: + + # The date needs to be formatted as a string. Add extra timezone details if required + date:str = parser.parse(data['completion_time']).strftime('%Y-%m-%d %H-%M-%S') + return cls( initial_balance=data["initial_balance"], balance=data["balance"], creation_height=data["creation_height"], - completion_time=parser.parse(data["completion_time"]), + completion_time=date ) def to_proto(self) -> UnbondingDelegationEntry_pb: diff --git a/terra_sdk/core/staking/data/validator.py b/terra_sdk/core/staking/data/validator.py index 57b1bfb..8e4da16 100644 --- a/terra_sdk/core/staking/data/validator.py +++ b/terra_sdk/core/staking/data/validator.py @@ -93,9 +93,13 @@ def to_amino(self) -> dict: @classmethod def from_data(cls, data: dict) -> Commission: + + # The date needs to be formatted as a string. Add extra timezone details if required + date:str = parser.parse(data['update_time']).strftime('%Y-%m-%d %H-%M-%S') + return cls( commission_rates=CommissionRates.from_data(data["commission_rates"]), - update_time=parser.parse(data["update_time"]), + update_time=date ) def to_proto(self) -> Commission_pb: