Skip to content

Commit

Permalink
Minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Serg-Norseman committed Dec 31, 2024
1 parent 9b590e5 commit da9a4c5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
33 changes: 17 additions & 16 deletions projects/GKCore/GDModel/Providers/GEDCOM/GEDCOMUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion projects/GKCore/GKCore/GKUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit da9a4c5

Please sign in to comment.