diff --git a/src/Utils.py b/src/Utils.py index 62f4a05b2..09c0d74a7 100644 --- a/src/Utils.py +++ b/src/Utils.py @@ -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 diff --git a/src/gen/datehandler/_dateutils.py b/src/gen/datehandler/_dateutils.py index 66734d03c..3c4d94c6d 100644 --- a/src/gen/datehandler/_dateutils.py +++ b/src/gen/datehandler/_dateutils.py @@ -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) diff --git a/src/gui/views/treemodels/citationbasemodel.py b/src/gui/views/treemodels/citationbasemodel.py index 62ecfffb0..9ef4b78e1 100644 --- a/src/gui/views/treemodels/citationbasemodel.py +++ b/src/gui/views/treemodels/citationbasemodel.py @@ -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] diff --git a/src/gui/views/treemodels/eventmodel.py b/src/gui/views/treemodels/eventmodel.py index 5789021e3..72822cbf0 100644 --- a/src/gui/views/treemodels/eventmodel.py +++ b/src/gui/views/treemodels/eventmodel.py @@ -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' diff --git a/src/gui/views/treemodels/familymodel.py b/src/gui/views/treemodels/familymodel.py index 764e97253..77a292b35 100644 --- a/src/gui/views/treemodels/familymodel.py +++ b/src/gui/views/treemodels/familymodel.py @@ -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' diff --git a/src/gui/views/treemodels/mediamodel.py b/src/gui/views/treemodels/mediamodel.py index 56d84835e..21a2f1d7a 100644 --- a/src/gui/views/treemodels/mediamodel.py +++ b/src/gui/views/treemodels/mediamodel.py @@ -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' diff --git a/src/gui/views/treemodels/notemodel.py b/src/gui/views/treemodels/notemodel.py index 8575d3138..c7b5ef14c 100644 --- a/src/gui/views/treemodels/notemodel.py +++ b/src/gui/views/treemodels/notemodel.py @@ -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): """ diff --git a/src/gui/views/treemodels/peoplemodel.py b/src/gui/views/treemodels/peoplemodel.py index 4bbd685bd..60e5b294d 100644 --- a/src/gui/views/treemodels/peoplemodel.py +++ b/src/gui/views/treemodels/peoplemodel.py @@ -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]] diff --git a/src/gui/views/treemodels/placemodel.py b/src/gui/views/treemodels/placemodel.py index 04e06c702..1591fbedc 100644 --- a/src/gui/views/treemodels/placemodel.py +++ b/src/gui/views/treemodels/placemodel.py @@ -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' diff --git a/src/gui/views/treemodels/repomodel.py b/src/gui/views/treemodels/repomodel.py index 70c30f694..21bf64fa7 100644 --- a/src/gui/views/treemodels/repomodel.py +++ b/src/gui/views/treemodels/repomodel.py @@ -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]) diff --git a/src/gui/views/treemodels/sourcemodel.py b/src/gui/views/treemodels/sourcemodel.py index ca667a679..cfb8ce44b 100644 --- a/src/gui/views/treemodels/sourcemodel.py +++ b/src/gui/views/treemodels/sourcemodel.py @@ -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]