diff --git a/projects/GKCore/GDModel/Providers/GEDCOM/GEDCOMUtils.cs b/projects/GKCore/GDModel/Providers/GEDCOM/GEDCOMUtils.cs index 428459569..c9c325ee0 100644 --- a/projects/GKCore/GDModel/Providers/GEDCOM/GEDCOMUtils.cs +++ b/projects/GKCore/GDModel/Providers/GEDCOM/GEDCOMUtils.cs @@ -364,8 +364,6 @@ public static string ParseTime(StringSpan strValue, out byte hour, out byte minu strValue = strTok.GetRest(); } - //time.SetRawData(hour, minutes, seconds, fraction); - return strValue; } @@ -937,20 +935,19 @@ public static MemoryStream DecodeBlob(string blob) public static string ParseDate(GDMTree owner, StringSpan strValue, out DateTime date) { - GDMApproximated approximated; - GDMCalendar calendar; short year; - bool yearBC; - string yearModifier; - byte month; - byte day; + byte month, day; var strTok = GEDCOMParser.Default; strTok.Reset(strValue); - string result = ParseDate(owner, strTok, out approximated, out calendar, out year, out yearBC, - out yearModifier, out month, out day); + string result = ParseDate(owner, strTok, out _, out _, out year, out _, out _, out month, out day); - date = new DateTime(year, month, day); + try { + date = new DateTime(year, month, day); + } catch (Exception ex) { + Logger.WriteError(string.Format("GEDCOMUtils.ParseDate({0}-{1}-{2}): ", year, month, day), ex); + date = DateTime.MinValue; + } return result; } @@ -982,13 +979,17 @@ public static string GetTimeStr(TimeSpan time) public static string ParseTime(StringSpan strValue, out TimeSpan time) { - byte hour; - byte minutes; - byte seconds; + byte hour, minutes, seconds; short fraction; - strValue = ParseTime(strValue, out hour, out minutes, out seconds, out fraction); - time = new TimeSpan(0, hour, minutes, seconds, (int)(100u * fraction)); + try { + strValue = ParseTime(strValue, out hour, out minutes, out seconds, out fraction); + time = new TimeSpan(0, hour, minutes, seconds, (int)(100u * fraction)); + } catch (Exception ex) { + Logger.WriteError(string.Format("GEDCOMUtils.ParseTime({0}): ", strValue), ex); + time = TimeSpan.Zero; + } + return strValue; } diff --git a/projects/GKCore/GKCore/GKUtils.cs b/projects/GKCore/GKCore/GKUtils.cs index 491587332..b1f777969 100644 --- a/projects/GKCore/GKCore/GKUtils.cs +++ b/projects/GKCore/GKCore/GKUtils.cs @@ -322,7 +322,7 @@ public static string GetRecordName(GDMTree tree, GDMRecord record, bool signed) st = ((GDMNoteRecord)record).Lines[0]; // TODO: bad solution?! break; case GDMRecordType.rtMultimedia: - st = ((GDMMultimediaRecord)record).FileReferences[0].Title; + st = ((GDMMultimediaRecord)record).GetFileTitle(); break; case GDMRecordType.rtSource: st = ((GDMSourceRecord)record).ShortTitle;