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 gen.lib
import Errors import Errors
from GrampsLocale import codeset from GrampsLocale import codeset
from Date import Date
import DateHandler
from const import TEMP_DIR, USER_HOME, GRAMPS_UUID from const import TEMP_DIR, USER_HOME, GRAMPS_UUID
import constfunc import constfunc
@ -1376,3 +1378,17 @@ def navigation_label(db, nav_type, handle):
label = '[%s] %s' % (obj.get_gramps_id(), label) label = '[%s] %s' % (obj.get_gramps_id(), label)
return (label, obj) 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 # python modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import time
import cgi import cgi
import logging import logging
log = logging.getLogger(".") log = logging.getLogger(".")
@ -42,7 +41,6 @@ import gtk
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import ToolTips import ToolTips
import GrampsLocale
import DateHandler import DateHandler
import gen.lib import gen.lib
import Utils import Utils
@ -154,9 +152,7 @@ class EventModel(FlatBaseModel):
return "%012x" % data[COLUMN_CHANGE] return "%012x" % data[COLUMN_CHANGE]
def column_change(self,data): def column_change(self,data):
return unicode(time.strftime('%x %X', return Utils.format_time(data[COLUMN_CHANGE])
time.localtime(data[COLUMN_CHANGE])),
GrampsLocale.codeset)
def column_tooltip(self,data): def column_tooltip(self,data):
try: try:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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