public void SetType(GEDDate.Types newtype) { //if (second) // gd2.Type = newtype; //else gd.Type = newtype; }
private void Set(int day, int mon, int year, GEDDate.Types type, ref GEDDate tomod) { tomod.Day = day; // TODO may be invalid tomod.Month = mon; tomod.Year = year; // TODO may be invalid tomod.Type = type; }
public void Set(int day, int mon, int year, GEDDate.Types type, bool second) { if (second) { Set(day, mon, year, type, ref gd2); } else { Set(day, mon, year, type, ref gd); } }
private void TestPrefix(string pref, GEDDate.Types target, bool?isStandard) { // TODO isStandard: verify flagged as (not)standard string val = "17 May 1972"; GEDDate res = ParseForDate(pref + val); Assert.AreEqual(target, res.Type, pref); if (!isStandard.HasValue) { return; // Couldn't parse: values not expected } Assert.AreEqual(1972, res.Year, pref); Assert.AreEqual(5, res.Month, pref); Assert.AreEqual(17, res.Day, pref); Assert.IsFalse(res.IsBC, pref); }
// No key, exact date: date to julian, range=1 [Exact] // No key, range date, no month: beg of year to julian, range=365/366 [Between][Range] // No key, range date, month: beg of month to julian, range=month length [Between][Range] // firstKey: (no secondkey) // before - beg of date to julian [Before][Range] // after - end of date to julian [After][Range] // from - beg of date to julian [After][Period] // initialTo - end of date to julian [before][Period] // firstkey with second key: // from - beg of date1 to end of date2 [Between][Period] // between - beg of date1 to end of date2 [between][Range] private static void MakeJulianDayRange(Context ctx, KeyW firstKey, KeyW secondKey) { long jdn = 0; long range = 0; GEDDate.Types finalType = ctx.gd.Type; switch (firstKey) { case KeyW.None: case KeyW.Estimate: jdn = StartToJulian(ctx.gd); long jdn2 = jdn + 1; if (ctx.gd.Type != GEDDate.Types.Exact) { jdn2 = EndToJulian(ctx.gd); } range = jdn2 - jdn; if (firstKey == KeyW.Estimate) { finalType = GEDDate.Types.Estimated; } // TODO e.g. "1910 to 1920" needs to be marked non-standard break; case KeyW.Before: jdn = StartToJulian(ctx.gd); finalType = GEDDate.Types.Before; // TODO mark as range? break; case KeyW.After: jdn = EndToJulian(ctx.gd); finalType = GEDDate.Types.After; // TODO mark as range? break; case KeyW.InitialTo: jdn = EndToJulian(ctx.gd); finalType = GEDDate.Types.Before; // TODO mark as period? break; case KeyW.From: jdn = StartToJulian(ctx.gd); if (secondKey == KeyW.None) { finalType = GEDDate.Types.After; // TODO mark as range? } else if (secondKey != KeyW.From) { finalType = GEDDate.Types.Unknown; // TODO error mark? } else { jdn2 = EndToJulian(ctx.gd2); range = jdn2 - jdn; finalType = GEDDate.Types.Range; // TODO mark as period? } break; case KeyW.Between: if (secondKey == KeyW.None || secondKey != KeyW.Between || ctx.gd2 == null) { finalType = GEDDate.Types.Unknown; // TODO error mark? break; } jdn = StartToJulian(ctx.gd); jdn2 = EndToJulian(ctx.gd2); range = jdn2 - jdn; finalType = GEDDate.Types.Range; // TODO mark as range? break; } ctx.gd.JDN = jdn; ctx.gd.JDR = range; ctx.gd.Type = finalType; }