diff --git a/deluge/common.py b/deluge/common.py index 1926c1894..27c690429 100644 --- a/deluge/common.py +++ b/deluge/common.py @@ -34,6 +34,7 @@ """Common functions for various parts of Deluge to use.""" import os +import time import subprocess import platform @@ -211,6 +212,12 @@ def ftime(seconds): return '%dw %dd' % (weeks, days) return 'unknown' +def fdate(value): + """Returns a date string, eg 05/05/08, given a time in seconds since the Epoch""" + if value < 0: + return "" + return time.strftime("%d/%m/%y", time.localtime(value)) + def is_url(url): """A simple regex test to check if the URL is valid.""" import re diff --git a/deluge/ui/gtkui/listview.py b/deluge/ui/gtkui/listview.py index 3cebc89b9..e822c0f4d 100644 --- a/deluge/ui/gtkui/listview.py +++ b/deluge/ui/gtkui/listview.py @@ -34,7 +34,6 @@ import cPickle import os.path -import time import pygtk pygtk.require('2.0') @@ -90,12 +89,8 @@ def cell_data_ratio(column, cell, model, row, data): cell.set_property('text', ratio_str) def cell_data_date(column, cell, model, row, data): - """Display value as date, eg 2008/05/05""" - time_val = model.get_value(row, data) - time_str = "" - if time_val > -1: - time_str = time.strftime("%d/%m/%y", time.localtime(time_val)) - cell.set_property('text', time_str) + """Display value as date, eg 05/05/08""" + cell.set_property('text', deluge.common.fdate(model.get_value(row, data))) class ListViewColumnState: """Used for saving/loading column state""" diff --git a/deluge/ui/gtkui/statistics_tab.py b/deluge/ui/gtkui/statistics_tab.py index b51b1b9a9..e36cdc087 100644 --- a/deluge/ui/gtkui/statistics_tab.py +++ b/deluge/ui/gtkui/statistics_tab.py @@ -33,7 +33,6 @@ # statement from all source files in the program, then also delete it here. import gtk, gtk.glade -import time from deluge.ui.client import aclient as client import deluge.component as component @@ -61,11 +60,6 @@ def fspeed(value, max_value=-1): else: return deluge.common.fspeed(value) -def fdate(value): - if value < 0: - return "" - return time.strftime("%d/%m/%y", time.localtime(value)) - class StatisticsTab(Tab): def __init__(self): Tab.__init__(self) @@ -95,7 +89,7 @@ class StatisticsTab(Tab): (glade.get_widget("summary_seed_rank"), str, ("seed_rank",)), (glade.get_widget("summary_auto_managed"), str, ("is_auto_managed",)), (glade.get_widget("progressbar"), fpcnt, ("progress",)), - (glade.get_widget("summary_date_added"), fdate, ("time_added",)) + (glade.get_widget("summary_date_added"), deluge.common.fdate, ("time_added",)) ] def update(self):