GEPS008: Move format_time into datehandler

svn: r19904
This commit is contained in:
Nick Hall 2012-06-23 18:34:50 +00:00
parent b359b16a21
commit 640e203693
11 changed files with 33 additions and 32 deletions

View File

@ -974,20 +974,6 @@ def navigation_label(db, nav_type, handle):
return (label, obj)
#-------------------------------------------------------------------------
#
# Format the date and time displayed in the Last Changed column in views.
#
#-------------------------------------------------------------------------
def format_time(secs):
"""
Format a time in seconds as a date in the preferred date format and a
24 hour time as hh:mm:ss.
"""
t = time.localtime(secs)
d = gen.lib.Date(t.tm_year, t.tm_mon, t.tm_mday)
return date_displayer.display(d) + time.strftime(' %X', t)
#-------------------------------------------------------------------------
#
# make_unknown

View File

@ -24,6 +24,14 @@
Class handling language-specific selection for date parser and displayer.
"""
#-------------------------------------------------------------------------
#
# Python modules
#
#-------------------------------------------------------------------------
import time
from gen.lib import Date
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -80,3 +88,12 @@ def get_date(date_base) :
def get_date_valid(date_base):
date_obj = date_base.get_date_object()
return date_obj.get_valid()
def format_time(secs):
"""
Format a time in seconds as a date in the preferred date format and a
24 hour time as hh:mm:ss.
"""
t = time.localtime(secs)
d = Date(t.tm_year, t.tm_mon, t.tm_mday)
return displayer.display(d) + time.strftime(' %X', t)

View File

@ -41,7 +41,7 @@ LOG = logging.getLogger(".citation")
#-------------------------------------------------------------------------
import gen.datehandler
import gen.lib
from Utils import confidence, format_time
from Utils import confidence
from gen.config import config
#-------------------------------------------------------------------------
@ -116,7 +116,7 @@ class CitationBaseModel(object):
return unicode(data[COLUMN_HANDLE])
def citation_change(self, data):
return format_time(data[COLUMN_CHANGE])
return gen.datehandler.format_time(data[COLUMN_CHANGE])
def citation_sort_change(self, data):
return "%012x" % data[COLUMN_CHANGE]
@ -168,7 +168,7 @@ class CitationBaseModel(object):
source_handle = data[COLUMN_SOURCE]
try:
source = self.db.get_source_from_handle(source_handle)
return format_time(source.change)
return gen.datehandler.format_time(source.change)
except:
return u''
@ -196,7 +196,7 @@ class CitationBaseModel(object):
return unicode(data[COLUMN2_PUBINFO])
def source_src_chan(self, data):
return format_time(data[COLUMN2_CHANGE])
return gen.datehandler.format_time(data[COLUMN2_CHANGE])
def source_sort2_change(self, data):
return "%012x" % data[COLUMN2_CHANGE]

View File

@ -162,7 +162,7 @@ class EventModel(FlatBaseModel):
return "%012x" % data[COLUMN_CHANGE]
def column_change(self,data):
return Utils.format_time(data[COLUMN_CHANGE])
return gen.datehandler.format_time(data[COLUMN_CHANGE])
def column_tooltip(self,data):
return u'Event tooltip'

View File

@ -173,7 +173,7 @@ class FamilyModel(FlatBaseModel):
return "%012x" % data[12]
def column_change(self, data):
return Utils.format_time(data[12])
return gen.datehandler.format_time(data[12])
def column_tooltip(self, data):
return u'Family tooltip'

View File

@ -42,7 +42,6 @@ import gtk
# GRAMPS modules
#
#-------------------------------------------------------------------------
import Utils
import gen.datehandler
import gen.lib
from gui.views.treemodels.flatbasemodel import FlatBaseModel
@ -151,7 +150,7 @@ class MediaModel(FlatBaseModel):
return "%012x" % data[8]
def column_change(self,data):
return Utils.format_time(data[8])
return gen.datehandler.format_time(data[8])
def column_tooltip(self,data):
return u'Media tooltip'

View File

@ -41,7 +41,7 @@ import gtk
# GRAMPS modules
#
#-------------------------------------------------------------------------
import Utils
import gen.datehandler
from gui.views.treemodels.flatbasemodel import FlatBaseModel
from gen.lib import (Note, NoteType, StyledText)
@ -129,7 +129,7 @@ class NoteModel(FlatBaseModel):
return "%012x" % data[Note.POS_CHANGE]
def column_change(self,data):
return Utils.format_time(data[Note.POS_CHANGE])
return gen.datehandler.format_time(data[Note.POS_CHANGE])
def get_tag_name(self, tag_handle):
"""

View File

@ -59,7 +59,6 @@ _LOG = logging.getLogger(".")
from gen.lib import Name, EventRef, EventType, EventRoleType
from gen.display.name import displayer as name_displayer
import gen.datehandler
import Utils
from lru import LRU
from gui.views.treemodels.flatbasemodel import FlatBaseModel
from gui.views.treemodels.treebasemodel import TreeBaseModel
@ -237,7 +236,7 @@ class PeopleBaseModel(object):
return "%012x" % data[COLUMN_CHANGE]
def column_change(self, data):
return Utils.format_time(data[COLUMN_CHANGE])
return gen.datehandler.format_time(data[COLUMN_CHANGE])
def column_gender(self, data):
return PeopleBaseModel._GENDER[data[COLUMN_GENDER]]

View File

@ -46,7 +46,7 @@ import gtk
# GRAMPS modules
#
#-------------------------------------------------------------------------
import Utils
import gen.datehandler
from gen.utils.place import conv_lat_lon
from gui.views.treemodels.flatbasemodel import FlatBaseModel
from gui.views.treemodels.treebasemodel import TreeBaseModel
@ -222,7 +222,7 @@ class PlaceBaseModel(object):
return "%012x" % data[11]
def column_change(self, data):
return Utils.format_time(data[11])
return gen.datehandler.format_time(data[11])
def column_tooltip(self, data):
return u'Place tooltip'

View File

@ -40,7 +40,7 @@ import gtk
#
#-------------------------------------------------------------------------
import gen.lib
import Utils
import gen.datehandler
from gui.views.treemodels.flatbasemodel import FlatBaseModel
#-------------------------------------------------------------------------
@ -231,4 +231,4 @@ class RepositoryModel(FlatBaseModel):
return "%012x" % data[7]
def column_change(self,data):
return Utils.format_time(data[7])
return gen.datehandler.format_time(data[7])

View File

@ -39,7 +39,7 @@ import gtk
# GRAMPS modules
#
#-------------------------------------------------------------------------
import Utils
import gen.datehandler
from gui.views.treemodels.flatbasemodel import FlatBaseModel
#-------------------------------------------------------------------------
@ -107,7 +107,7 @@ class SourceModel(FlatBaseModel):
return unicode(data[4])
def column_change(self,data):
return Utils.format_time(data[8])
return gen.datehandler.format_time(data[8])
def sort_change(self,data):
return "%012x" % data[8]