Beispiel #1
0
        public static bool IsCensusYear(FactDate fd, string Country, bool exactYear)
        {
            switch (Country)
            {
            case Countries.UNITED_STATES:
                return(US_FEDERAL_CENSUS.Any(cd => fd.Overlaps(cd)));

            case Countries.CANADA:
                return(CANADIAN_CENSUS.Any(cd => fd.Overlaps(cd)));

            default:
                return(SUPPORTED_CENSUS.Any(cd =>
                                            (exactYear && fd.CensusYearMatches(cd)) || (!exactYear && fd.Overlaps(cd))));
            }
        }
Beispiel #2
0
 public static CensusDate GetLostCousinsCensusYear(FactDate fd, bool exactYear)
 {
     foreach (CensusDate cd in LOSTCOUSINS_CENSUS)
     {
         if (exactYear && fd.YearMatches(cd))
         {
             return(cd);
         }
         if (!exactYear && fd.Overlaps(cd))
         {
             return(cd);
         }
     }
     return(null);
 }
Beispiel #3
0
 public static bool IsUKCensusYear(FactDate fd, bool exactYear)
 {
     foreach (CensusDate cd in UK_CENSUS)
     {
         if (exactYear && fd.YearMatches(cd))
         {
             return(true);
         }
         if (!exactYear && fd.Overlaps(cd))
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #4
0
 public static CensusDate GetLostCousinsCensusYear(FactDate fd, bool exactYear) =>
 LOSTCOUSINS_CENSUS.FirstOrDefault(
     cd => (exactYear && fd.CensusYearMatches(cd)) || (!exactYear && fd.Overlaps(cd))
     );
Beispiel #5
0
 public static bool IsUKCensusYear(FactDate fd, bool exactYear) =>
 UK_CENSUS.Any(cd =>
               (exactYear && fd.CensusYearMatches(cd)) || (!exactYear && fd.Overlaps(cd))
               );
Beispiel #6
0
        private void CheckCensusDate(string tag)
        {
            FactDate yearAdjusted = FactDate;

            // check if census fails to overlaps a census date
            if ((tag == "Census 1841" && !FactDate.Overlaps(CensusDate.UKCENSUS1841)) ||
                (tag == "Census 1851" && !FactDate.Overlaps(CensusDate.UKCENSUS1851)) ||
                (tag == "Census 1861" && !FactDate.Overlaps(CensusDate.UKCENSUS1861)) ||
                (tag == "Census 1871" && !FactDate.Overlaps(CensusDate.UKCENSUS1871)) ||
                (tag == "Census 1881" && !FactDate.Overlaps(CensusDate.UKCENSUS1881)) ||
                (tag == "Census 1891" && !FactDate.Overlaps(CensusDate.UKCENSUS1891)) ||
                (tag == "Census 1901" && !FactDate.Overlaps(CensusDate.UKCENSUS1901)) ||
                (tag == "Census 1911" && !FactDate.Overlaps(CensusDate.UKCENSUS1911)) ||
                (tag == "Census 1939" && !FactDate.Overlaps(CensusDate.UKCENSUS1939)) ||
                (tag == "Census" && !CensusDate.IsUKCensusYear(FactDate, false)) ||
                ((tag == "Lost Cousins" || tag == "LostCousins") && !CensusDate.IsLostCousinsCensusYear(FactDate, false)) &&
                FactDate.DateString.Length >= 4)
            {
                // if not a census overlay then set date to year and try that instead
                string year   = FactDate.DateString.Substring(FactDate.DateString.Length - 4);
                int    result = 0;
                if (Int32.TryParse(year, out result))
                {
                    yearAdjusted = new FactDate(year);
                    if (Properties.GeneralSettings.Default.TolerateInaccurateCensusDate)
                    {
                        //                        this.FactErrorNumber = (int)FamilyTree.Dataerror.RESIDENCE_CENSUS_DATE;
                        this.FactErrorMessage = "Warning: Inaccurate Census date '" + FactDate + "' treated as '" + yearAdjusted + "'";
                        this.FactErrorLevel   = Fact.FactError.WARNINGALLOW;
                    }
                    else
                    {
                        //                        this.FactErrorNumber = (int)FamilyTree.Dataerror.RESIDENCE_CENSUS_DATE;
                        this.FactErrorLevel   = Fact.FactError.WARNINGIGNORE;
                        this.FactErrorMessage = "Inaccurate Census date '" + FactDate + "' fact ignored in strict mode. Check for incorrect date entered or try Tolerate slightly inaccurate census date option.";
                    }
                }
            }
            if ((tag == "Census 1841" && !yearAdjusted.Overlaps(CensusDate.UKCENSUS1841)) ||
                (tag == "Census 1851" && !yearAdjusted.Overlaps(CensusDate.UKCENSUS1851)) ||
                (tag == "Census 1861" && !yearAdjusted.Overlaps(CensusDate.UKCENSUS1861)) ||
                (tag == "Census 1871" && !yearAdjusted.Overlaps(CensusDate.UKCENSUS1871)) ||
                (tag == "Census 1881" && !yearAdjusted.Overlaps(CensusDate.UKCENSUS1881)) ||
                (tag == "Census 1891" && !yearAdjusted.Overlaps(CensusDate.UKCENSUS1891)) ||
                (tag == "Census 1901" && !yearAdjusted.Overlaps(CensusDate.UKCENSUS1901)) ||
                (tag == "Census 1911" && !yearAdjusted.Overlaps(CensusDate.UKCENSUS1911)) ||
                (tag == "Census 1939" && !yearAdjusted.Overlaps(CensusDate.UKCENSUS1939)))
            {
                this.FactErrorMessage = "UK Census fact error date '" + FactDate + "' doesn't match '" + tag + "' tag. Check for incorrect date entered.";
                this.FactErrorLevel   = FactError.ERROR;
                //                this.FactErrorNumber = (int)FamilyTree.Dataerror.CENSUS_COVERAGE;
                return;
            }
            if (tag == "Census" || tag == "LostCousins" || tag == "Lost Cousins")
            {
                TimeSpan ts = FactDate.EndDate - FactDate.StartDate;
                if (ts.Days > 3650)
                {
                    //                    this.FactErrorNumber = (int)FamilyTree.Dataerror.CENSUS_COVERAGE;
                    this.FactErrorLevel   = FactError.ERROR;
                    this.FactErrorMessage = "Date covers more than one census.";
                    return;
                }
            }
            if (tag == "Census")
            {
                if (!CensusDate.IsCensusYear(yearAdjusted, false))
                {
                    //                    this.FactErrorNumber = (int)FamilyTree.Dataerror.CENSUS_COVERAGE;
                    this.FactErrorMessage = "Census fact error date '" + FactDate + "' isn't a supported census date. Check for incorrect date entered or try Tolerate slightly inaccurate census date option.";
                    this.FactErrorLevel   = FactError.ERROR;
                    return;
                }
                if (Properties.GeneralSettings.Default.TolerateInaccurateCensusDate && yearAdjusted.IsKnown && !CensusDate.IsCensusYear(yearAdjusted, true))
                {
                    //                    this.FactErrorNumber = (int)FamilyTree.Dataerror.CENSUS_COVERAGE;
                    this.FactErrorMessage = "Warning : Census fact error date '" + FactDate + "' overlaps census date but is vague. Check for incorrect date entered.";
                    this.FactErrorLevel   = FactError.WARNINGALLOW;
                }
                if (!FactDate.Equals(yearAdjusted))
                {
                    FactDate = yearAdjusted;
                }
            }
            if (tag == "Lost Cousins" || tag == "LostCousins")
            {
                if (Properties.GeneralSettings.Default.TolerateInaccurateCensusDate && yearAdjusted.IsKnown && !CensusDate.IsLostCousinsCensusYear(yearAdjusted, true))
                {
                    //                    this.FactErrorNumber = (int)FamilyTree.Dataerror.CENSUS_COVERAGE;
                    this.FactErrorMessage = "Lost Cousins fact error date '" + FactDate + "' overlaps Lost Cousins census year but is vague. Check for incorrect date entered.";
                    this.FactErrorLevel   = Fact.FactError.WARNINGALLOW;
                }
                if (!CensusDate.IsLostCousinsCensusYear(yearAdjusted, false))
                {
                    //                    this.FactErrorNumber = (int)FamilyTree.Dataerror.CENSUS_COVERAGE;
                    this.FactErrorMessage = "Lost Cousins fact error date '" + FactDate + "' isn't a supported Lost Cousins census year. Check for incorrect date entered or try Tolerate slightly inaccurate census date option.";
                    this.FactErrorLevel   = Fact.FactError.ERROR;
                }
                if (!FactDate.Equals(yearAdjusted))
                {
                    FactDate = yearAdjusted;
                }
            }
        }