1
0

add section dependent datetime formatting

This commit is contained in:
Sander van Grieken
2022-05-06 12:02:17 +02:00
parent 4cc3acabb3
commit 52c1ed10dc

View File

@@ -74,8 +74,20 @@ class QETransactionListModel(QAbstractListModel):
else:
item['section'] = 'older'
item['date'] = self.format_date_by_section(item['section'], datetime.fromtimestamp(item['timestamp']))
return item
def format_date_by_section(self, section, date):
#TODO: l10n
dfmt = {
'today': '%H:%M:%S',
'yesterday': '%H:%M:%S',
'lastweek': '%a, %H:%M:%S',
'lastmonth': '%a %d, %H:%M:%S',
'older': '%G-%m-%d %H:%M:%S'
}[section]
return date.strftime(dfmt)
# initial model data
def init_model(self):
history = self.wallet.get_detailed_history(show_addresses = True)
@@ -96,7 +108,7 @@ class QETransactionListModel(QAbstractListModel):
tx['height'] = info.height
tx['confirmations'] = info.conf
tx['timestamp'] = info.timestamp
tx['date'] = datetime.fromtimestamp(info.timestamp)
tx['date'] = self.format_date_by_section(datetime.fromtimestamp(info.timestamp), tx['section'])
index = self.index(i,0)
roles = [self._ROLE_RMAP[x] for x in ['height','confirmations','timestamp','date']]
self.dataChanged.emit(index, index, roles)