2799: in GEDCOM export, changed timestamp for every single record is 31 DEC 1969

svn: r13630
This commit is contained in:
Benny Malengier 2009-11-18 22:45:54 +00:00
parent a82e3161ca
commit 1846c513cf
4 changed files with 34 additions and 9 deletions

View File

@ -3490,7 +3490,7 @@ class GedcomParser(UpdateCallback):
@type state: CurrentState @type state: CurrentState
""" """
state.repo_ref.set_call_number(line.data) state.repo_ref.set_call_number(line.data)
self.__skip_subordinate_levels(state.level+1) #self.__skip_subordinate_levels(state.level+1)
def __repo_ref_medi(self, line, state): def __repo_ref_medi(self, line, state):
name = line.data name = line.data
@ -4167,20 +4167,28 @@ class GedcomParser(UpdateCallback):
elif line.token == TOKEN_TIME: elif line.token == TOKEN_TIME:
tstr = line.data tstr = line.data
elif line.token == TOKEN_DATE: elif line.token == TOKEN_DATE:
dstr = line.data #GedcomLex converted already to Date object
dobj = line.data
elif line.token == TOKEN_NOTE: elif line.token == TOKEN_NOTE:
self.__skip_subordinate_levels(level+1) self.__skip_subordinate_levels(level+1)
else: else:
self.__not_recognized(line, level+1) self.__not_recognized(line, level+1)
# Attempt to convert the values to a valid change time # Attempt to convert the values to a valid change time
if tstr: if dobj:
dstr = "%s %s %s" % (dobj.get_day(), dobj.get_month(),
dobj.get_year())
try: try:
if dstr: if tstr:
tstruct = time.strptime("%s %s" % (dstr, tstr), try:
"%d %b %Y %H:%M:%S") tstruct = time.strptime("%s %s" % (dstr, tstr),
"%d %m %Y %H:%M:%S")
except ValueError:
#seconds is optional in GEDCOM
tstruct = time.strptime("%s %s" % (dstr, tstr),
"%d %m %Y %H:%M")
else: else:
tstruct = time.strptime(tstr, "%d %b %Y") tstruct = time.strptime(dstr, "%d %m %Y")
val = time.mktime(tstruct) val = time.mktime(tstruct)
obj.change = val obj.change = val
except ValueError: except ValueError:

View File

@ -106,6 +106,17 @@ class BasicPrimaryObject(BaseObject, PrivacyBase):
""" """
return self.change return self.change
def set_change_time(self, change):
"""
Modify the time that the data was last changed.
The value must be in the format returned by the time.time() command.
@param change: new time
@type change: int in format as time.time() command
"""
self.change = change
def get_change_display(self): def get_change_display(self):
""" """
Return the string representation of the last change time. Return the string representation of the last change time.

View File

@ -265,10 +265,9 @@ class LivingProxyDb(ProxyDbBase):
new_person.set_gender(person.get_gender()) new_person.set_gender(person.get_gender())
new_person.set_gramps_id(person.get_gramps_id()) new_person.set_gramps_id(person.get_gramps_id())
new_person.set_handle(person.get_handle()) new_person.set_handle(person.get_handle())
new_person.set_change_time(person.get_change_time())
new_person.set_family_handle_list(person.get_family_handle_list()) new_person.set_family_handle_list(person.get_family_handle_list())
new_person.set_parent_family_handle_list( new_person.set_parent_family_handle_list(
person.get_parent_family_handle_list() ) person.get_parent_family_handle_list() )
return new_person return new_person

View File

@ -728,6 +728,7 @@ def sanitize_person(db, person):
new_person.set_gender(person.get_gender()) new_person.set_gender(person.get_gender())
new_person.set_gramps_id(person.get_gramps_id()) new_person.set_gramps_id(person.get_gramps_id())
new_person.set_handle(person.get_handle()) new_person.set_handle(person.get_handle())
new_person.set_change_time(person.get_change_time())
# copy names if not private # copy names if not private
name = person.get_primary_name() name = person.get_primary_name()
@ -818,6 +819,7 @@ def sanitize_source(db, source):
new_source.set_abbreviation(source.get_abbreviation()) new_source.set_abbreviation(source.get_abbreviation())
new_source.set_gramps_id(source.get_gramps_id()) new_source.set_gramps_id(source.get_gramps_id())
new_source.set_handle(source.get_handle()) new_source.set_handle(source.get_handle())
new_source.set_change_time(source.get_change_time())
new_source.set_marker(source.get_marker()) new_source.set_marker(source.get_marker())
new_source.set_data_map(source.get_data_map()) new_source.set_data_map(source.get_data_map())
@ -854,6 +856,7 @@ def sanitize_media(db, media):
new_media.set_description(media.get_description()) new_media.set_description(media.get_description())
new_media.set_gramps_id(media.get_gramps_id()) new_media.set_gramps_id(media.get_gramps_id())
new_media.set_handle(media.get_handle()) new_media.set_handle(media.get_handle())
new_media.set_change_time(media.get_change_time())
new_media.set_date_object(media.get_date_object()) new_media.set_date_object(media.get_date_object())
new_media.set_marker(media.get_marker()) new_media.set_marker(media.get_marker())
@ -882,6 +885,7 @@ def sanitize_place(db, place):
new_place.set_title(place.get_title()) new_place.set_title(place.get_title())
new_place.set_gramps_id(place.get_gramps_id()) new_place.set_gramps_id(place.get_gramps_id())
new_place.set_handle(place.get_handle()) new_place.set_handle(place.get_handle())
new_place.set_change_time(place.get_change_time())
new_place.set_longitude(place.get_longitude()) new_place.set_longitude(place.get_longitude())
new_place.set_latitude(place.get_latitude()) new_place.set_latitude(place.get_latitude())
new_place.set_main_location(place.get_main_location()) new_place.set_main_location(place.get_main_location())
@ -917,6 +921,7 @@ def sanitize_event(db, event):
new_event.set_handle(event.get_handle()) new_event.set_handle(event.get_handle())
new_event.set_date_object(event.get_date_object()) new_event.set_date_object(event.get_date_object())
new_event.set_marker(event.get_marker()) new_event.set_marker(event.get_marker())
new_event.set_change_time(event.get_change_time())
copy_source_ref_list(db, event, new_event) copy_source_ref_list(db, event, new_event)
copy_notes(db, event, new_event) copy_notes(db, event, new_event)
@ -950,6 +955,7 @@ def sanitize_family(db, family):
new_family.set_handle(family.get_handle()) new_family.set_handle(family.get_handle())
new_family.set_marker(family.get_marker()) new_family.set_marker(family.get_marker())
new_family.set_relationship(family.get_relationship()) new_family.set_relationship(family.get_relationship())
new_family.set_change_time(family.get_change_time())
# Copy the father handle. # Copy the father handle.
father_handle = family.get_father_handle() father_handle = family.get_father_handle()
@ -1017,6 +1023,7 @@ def sanitize_repository(db, repository):
new_repository.set_name(repository.get_name()) new_repository.set_name(repository.get_name())
new_repository.set_gramps_id(repository.get_gramps_id()) new_repository.set_gramps_id(repository.get_gramps_id())
new_repository.set_handle(repository.get_handle()) new_repository.set_handle(repository.get_handle())
new_repository.set_change_time(repository.get_change_time())
new_repository.set_marker(repository.get_marker()) new_repository.set_marker(repository.get_marker())
copy_notes(db, repository, new_repository) copy_notes(db, repository, new_repository)