Move fdate() to common, patch from Lajnold

This commit is contained in:
Andrew Resch 2008-11-02 18:13:11 +00:00
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.""" """Common functions for various parts of Deluge to use."""
import os import os
import time
import subprocess import subprocess
import platform import platform
@ -211,6 +212,12 @@ def ftime(seconds):
return '%dw %dd' % (weeks, days) return '%dw %dd' % (weeks, days)
return 'unknown' 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): def is_url(url):
"""A simple regex test to check if the URL is valid.""" """A simple regex test to check if the URL is valid."""
import re import re

View file

@ -34,7 +34,6 @@
import cPickle import cPickle
import os.path import os.path
import time
import pygtk import pygtk
pygtk.require('2.0') pygtk.require('2.0')
@ -90,12 +89,8 @@ def cell_data_ratio(column, cell, model, row, data):
cell.set_property('text', ratio_str) cell.set_property('text', ratio_str)
def cell_data_date(column, cell, model, row, data): def cell_data_date(column, cell, model, row, data):
"""Display value as date, eg 2008/05/05""" """Display value as date, eg 05/05/08"""
time_val = model.get_value(row, data) cell.set_property('text', deluge.common.fdate(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)
class ListViewColumnState: class ListViewColumnState:
"""Used for saving/loading column state""" """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. # statement from all source files in the program, then also delete it here.
import gtk, gtk.glade import gtk, gtk.glade
import time
from deluge.ui.client import aclient as client from deluge.ui.client import aclient as client
import deluge.component as component import deluge.component as component
@ -61,11 +60,6 @@ def fspeed(value, max_value=-1):
else: else:
return deluge.common.fspeed(value) return deluge.common.fspeed(value)
def fdate(value):
if value < 0:
return ""
return time.strftime("%d/%m/%y", time.localtime(value))
class StatisticsTab(Tab): class StatisticsTab(Tab):
def __init__(self): def __init__(self):
Tab.__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_seed_rank"), str, ("seed_rank",)),
(glade.get_widget("summary_auto_managed"), str, ("is_auto_managed",)), (glade.get_widget("summary_auto_managed"), str, ("is_auto_managed",)),
(glade.get_widget("progressbar"), fpcnt, ("progress",)), (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): def update(self):