Format date in Last Changed column in views according to preference setting

svn: r15426
This commit is contained in:
Nick Hall 2010-05-20 17:47:31 +00:00
parent 8981551fcd
commit 6da2ade5e3
9 changed files with 31 additions and 35 deletions

View File

@ -47,6 +47,8 @@ from gen.display.name import displayer as name_displayer
import gen.lib
import Errors
from GrampsLocale import codeset
from Date import Date
import DateHandler
from const import TEMP_DIR, USER_HOME, GRAMPS_UUID
import constfunc
@ -1376,3 +1378,17 @@ def navigation_label(db, nav_type, handle):
label = '[%s] %s' % (obj.get_gramps_id(), label)
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 = Date(t.tm_year, t.tm_mon, t.tm_mday)
return DateHandler.displayer.display(d) + time.strftime(' %X', t)

View File

@ -24,7 +24,6 @@
# python modules
#
#-------------------------------------------------------------------------
import time
import cgi
import logging
log = logging.getLogger(".")
@ -42,7 +41,6 @@ import gtk
#
#-------------------------------------------------------------------------
import ToolTips
import GrampsLocale
import DateHandler
import gen.lib
import Utils
@ -154,9 +152,7 @@ class EventModel(FlatBaseModel):
return "%012x" % data[COLUMN_CHANGE]
def column_change(self,data):
return unicode(time.strftime('%x %X',
time.localtime(data[COLUMN_CHANGE])),
GrampsLocale.codeset)
return Utils.format_time(data[COLUMN_CHANGE])
def column_tooltip(self,data):
try:

View File

@ -24,7 +24,6 @@
# python modules
#
#-------------------------------------------------------------------------
import time
import logging
log = logging.getLogger(".")
@ -42,7 +41,7 @@ import gtk
#-------------------------------------------------------------------------
import const
import ToolTips
import GrampsLocale
import Utils
import DateHandler
from gen.display.name import displayer as name_displayer
import gen.lib
@ -153,8 +152,7 @@ class FamilyModel(FlatBaseModel):
return "%012x" % data[12]
def column_change(self, data):
return unicode(time.strftime('%x %X', time.localtime(data[12])),
GrampsLocale.codeset)
return Utils.format_time(data[12])
def column_marker_text(self, data):
try:

View File

@ -24,7 +24,6 @@
# python modules
#
#-------------------------------------------------------------------------
import time
from gen.ggettext import gettext as _
import logging
log = logging.getLogger(".")
@ -43,7 +42,7 @@ import gtk
#-------------------------------------------------------------------------
import const
import ToolTips
import GrampsLocale
import Utils
import DateHandler
import gen.lib
from gui.views.treemodels.flatbasemodel import FlatBaseModel
@ -130,8 +129,7 @@ class MediaModel(FlatBaseModel):
return "%012x" % data[8]
def column_change(self,data):
return unicode(time.strftime('%x %X',time.localtime(data[8])),
GrampsLocale.codeset)
return Utils.format_time(data[8])
def column_tooltip(self,data):
if const.USE_TIPS:

View File

@ -24,7 +24,6 @@
# python modules
#
#-------------------------------------------------------------------------
import time
import logging
_LOG = logging.getLogger(".gui.notemodel")
@ -40,7 +39,7 @@ import gtk
# GRAMPS modules
#
#-------------------------------------------------------------------------
import GrampsLocale
import Utils
from gui.views.treemodels.flatbasemodel import FlatBaseModel
from gen.lib import (Note, NoteType, MarkerType, StyledText)
@ -133,5 +132,4 @@ class NoteModel(FlatBaseModel):
return "%012x" % data[Note.POS_CHANGE]
def column_change(self,data):
return unicode(time.strftime('%x %X',time.localtime(
data[Note.POS_CHANGE])), GrampsLocale.codeset)
return Utils.format_time(data[Note.POS_CHANGE])

View File

@ -33,7 +33,6 @@ TreeModel for the GRAMPS Person tree.
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
import time
import cgi
#-------------------------------------------------------------------------
@ -61,7 +60,7 @@ from gen.lib import Name, EventRef, EventType, EventRoleType, MarkerType
from gen.display.name import displayer as name_displayer
import DateHandler
import ToolTips
import GrampsLocale
import Utils
from Lru import LRU
from gui.views.treemodels.flatbasemodel import FlatBaseModel
from gui.views.treemodels.treebasemodel import TreeBaseModel
@ -223,10 +222,7 @@ class PeopleBaseModel(object):
return "%012x" % data[COLUMN_CHANGE]
def column_change(self, data):
return unicode(
time.strftime('%x %X',
time.localtime(data[COLUMN_CHANGE])),
GrampsLocale.codeset)
return Utils.format_time(data[COLUMN_CHANGE])
def column_gender(self, data):
return PeopleBaseModel._GENDER[data[COLUMN_GENDER]]

View File

@ -30,7 +30,6 @@ Place Model.
# python modules
#
#-------------------------------------------------------------------------
import time
import cgi
import logging
_LOG = logging.getLogger(".gui.views.treemodels.placemodel")
@ -49,7 +48,7 @@ import gtk
#-------------------------------------------------------------------------
import const
import ToolTips
import GrampsLocale
import Utils
from gui.views.treemodels.flatbasemodel import FlatBaseModel
from gui.views.treemodels.treebasemodel import TreeBaseModel
@ -212,8 +211,7 @@ class PlaceBaseModel(object):
return "%012x" % data[11]
def column_change(self, data):
return unicode(time.strftime('%x %X',time.localtime(data[11])),
GrampsLocale.codeset)
return Utils.format_time(data[11])
def column_tooltip(self, data):
if const.USE_TIPS:

View File

@ -24,7 +24,6 @@
# python modules
#
#-------------------------------------------------------------------------
import time
import logging
log = logging.getLogger(".")
@ -41,7 +40,7 @@ import gtk
#
#-------------------------------------------------------------------------
import gen.lib
import GrampsLocale
import Utils
from gui.views.treemodels.flatbasemodel import FlatBaseModel
#-------------------------------------------------------------------------
@ -220,5 +219,4 @@ class RepositoryModel(FlatBaseModel):
return "%012x" % data[7]
def column_change(self,data):
return unicode(time.strftime('%x %X',time.localtime(data[7])),
GrampsLocale.codeset)
return Utils.format_time(data[7])

View File

@ -24,7 +24,6 @@
# python modules
#
#-------------------------------------------------------------------------
import time
import logging
log = logging.getLogger(".")
@ -42,7 +41,7 @@ import gtk
#-------------------------------------------------------------------------
import const
import ToolTips
import GrampsLocale
import Utils
from gui.views.treemodels.flatbasemodel import FlatBaseModel
#-------------------------------------------------------------------------
@ -99,8 +98,7 @@ class SourceModel(FlatBaseModel):
return unicode(data[4])
def column_change(self,data):
return unicode(time.strftime('%x %X',time.localtime(data[8])),
GrampsLocale.codeset)
return Utils.format_time(data[8])
def sort_change(self,data):
return "%012x" % data[8]