1
0

More improvements to exchange_rate plugin

- better historical rate handling, including caching
- grabbing and scanning wallet transactions no longer needed
- fix autosize of fiat column
- more efficient
This commit is contained in:
Neil Booth
2015-09-05 14:05:37 +09:00
parent 8d046c7919
commit 9da22000b6
3 changed files with 106 additions and 139 deletions

View File

@@ -7,6 +7,7 @@ import traceback
import urlparse
import urllib
import threading
from i18n import _
def normalize_version(v):
return [int(x) for x in re.sub(r'(\.0+)*$','', v).split(".")]
@@ -15,7 +16,6 @@ class NotEnoughFunds(Exception): pass
class InvalidPassword(Exception):
def __str__(self):
from i18n import _
return _("Incorrect password")
class MyEncoder(json.JSONEncoder):
@@ -182,13 +182,15 @@ def format_satoshis(x, is_diff=False, num_zeros = 0, decimal_point = 8, whitespa
result = " " * (15 - len(result)) + result
return result.decode('utf8')
def format_time(timestamp):
import datetime
def timestamp_to_datetime(timestamp):
try:
time_str = datetime.datetime.fromtimestamp(timestamp).isoformat(' ')[:-3]
return datetime.fromtimestamp(timestamp)
except:
time_str = "unknown"
return time_str
return None
def format_time(timestamp):
date = timestamp_to_datetime(timestamp)
return date.isoformat(' ')[:-3] if date else _("Unknown")
# Takes a timestamp and returns a string with the approximation of the age