Skip to content
Snippets Groups Projects
Commit a9e5e062 authored by matograine's avatar matograine
Browse files

[mod] #344 use pendulum in tx_history

parent 8c9e5406
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +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/>.
"""
from pendulum import from_timestamp
from click import command, argument, option, echo_via_pager, get_terminal_size
from texttable import Texttable
from operator import itemgetter, neg, eq, ne
......@@ -25,11 +26,12 @@ from duniterpy.documents.transaction import Transaction
from silkaj.network_tools import ClientInstance
from silkaj.tools import coroutine
from silkaj.tui import convert_time, display_pubkey_and_checksum
from silkaj.tui import display_pubkey_and_checksum
from silkaj.crypto_tools import validate_checksum, check_pubkey_format
from silkaj import wot
from silkaj.money import get_amount_from_pubkey, amount_in_current_base, UDValue
from silkaj.tools import CurrencySymbol
from silkaj.constants import ALL, ALL_DIGITAL
@command("history", help="Display transaction history")
......@@ -65,14 +67,14 @@ async def generate_header(pubkey, currency_symbol, ud_value):
idty = dict([("uid", "")])
balance = await get_amount_from_pubkey(pubkey)
return "Transactions history from: {uid} {pubkey}\n\
Current balance: {balance} {currency}, {balance_ud} UD {currency} on the {date}\n\
Current balance: {balance} {currency}, {balance_ud} UD {currency} on {date}\n\
".format(
uid=idty["uid"],
pubkey=display_pubkey_and_checksum(pubkey),
currency=currency_symbol,
balance=balance[1] / 100,
balance_ud=round(balance[1] / ud_value, 2),
date=convert_time(time(), "all"),
date=from_timestamp(time()).format(ALL),
)
......@@ -150,7 +152,7 @@ async def parse_received_tx(
identities = await wot.identities_from_pubkeys(issuers, uids)
for received_tx in received_txs:
tx_list = list()
tx_list.append(convert_time(received_tx.time, "all"))
tx_list.append(from_timestamp(received_tx.time).format(ALL_DIGITAL))
tx_list.append(str())
for i, issuer in enumerate(received_tx.issuers):
tx_list[1] += prefix(None, None, i) + assign_idty_from_pubkey(
......@@ -182,7 +184,7 @@ async def parse_sent_tx(sent_txs_table, sent_txs, pubkey, ud_value, uids, full_p
identities = await wot.identities_from_pubkeys(pubkeys, uids)
for sent_tx in sent_txs:
tx_list = list()
tx_list.append(convert_time(sent_tx.time, "all"))
tx_list.append(from_timestamp(sent_tx.time).format(ALL_DIGITAL))
total_amount, outputs = tx_amount(sent_tx, pubkey, sent_func)
if len(outputs) > 1:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment