From 60cc32f28de28b67a371e9b0509747becf397e5a Mon Sep 17 00:00:00 2001
From: matograine <tom.ngr@zaclys.net>
Date: Mon, 26 Apr 2021 17:09:36 +0200
Subject: [PATCH] [mod] #344 use pendulum in silkaj.wot

---
 silkaj/wot.py | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/silkaj/wot.py b/silkaj/wot.py
index 366c696a..b26d1fbe 100644
--- a/silkaj/wot.py
+++ b/silkaj/wot.py
@@ -15,7 +15,7 @@ You should have received a copy of the GNU Affero General Public License
 along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
 """
 
-import click
+import click, pendulum
 from time import time
 from tabulate import tabulate
 from collections import OrderedDict
@@ -26,9 +26,9 @@ from duniterpy.api.errors import DuniterError
 from silkaj.network_tools import ClientInstance
 from silkaj.crypto_tools import is_pubkey_and_check
 from silkaj.tools import message_exit, coroutine
-from silkaj.tui import convert_time, display_pubkey_and_checksum
+from silkaj.tui import display_pubkey_and_checksum
 from silkaj.blockchain_tools import BlockchainParams
-from silkaj.constants import ASYNC_SLEEP
+from silkaj.constants import ASYNC_SLEEP, DATE
 
 
 def get_sent_certifications(signed, time_first_block, params):
@@ -132,25 +132,24 @@ async def membership_status(certifications, pubkey, req):
             "revoked:",
             req["revoked"],
             "\nrevoked on:",
-            convert_time(req["revoked_on"], "date") + "\n",
+            pendulum.from_timestamp(req["revoked_on"]).format(DATE) + "\n",
         )
     if not member and req["wasMember"]:
         print("expired:", req["expired"], "\nwasMember:", req["wasMember"])
     elif member:
         print(
             "Membership document expiration: "
-            + convert_time(time() + req["membershipExpiresIn"], "date")
+            + pendulum.from_timestamp(time() + req["membershipExpiresIn"]).format(DATE)
         )
         print("Sentry:", req["isSentry"])
     print("outdistanced:", req["outdistanced"])
 
 
 def expiration_date_from_block_id(block_id, time_first_block, params):
-    return convert_time(
+    return pendulum.from_timestamp(
         date_approximation(block_id, time_first_block, params["avgGenTime"])
-        + params["sigValidity"],
-        "date",
-    )
+        + params["sigValidity"]
+    ).format(DATE)
 
 
 def date_approximation(block_id, time_first_block, avgentime):
-- 
GitLab