Move fdate() to common, patch from Lajnold

This commit is contained in:
Andrew Resch 2008-11-02 18:13:11 +00:00
parent 3ecf6a187e
commit f4d7080492
3 changed files with 10 additions and 14 deletions

View File

@ -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

View File

@ -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"""

View File

@ -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):