SobekCM.Resource_Object.Mapping.Standard_Bibliographic_Mapper.build_date_string C# (CSharp) Method

build_date_string() private method

Builds a complete date string based on each of the individual components passed in through the mappings ( day, month, year )
private build_date_string ( SobekCM_Item Package ) : void
Package SobekCM_Item Item to add the built date string to
return void
        private void build_date_string(SobekCM_Item Package)
        {
            // check if all the date components exist in the static variables
            if ((month.Length > 0) && (day.Length > 0) && (year.Length > 0))
            {
                date_string = month + day + year;
                string expression = @"\d{" + date_string.Length + "}";
                if (Regex.IsMatch(date_string, expression))
                {
                    // the date string is numeric; separate the date parts with a slash ("/") character.
                    date_string = month + "/" + day + "/" + year;
                }
                else
                {
                    // the date string is not numeric; separate the date parts with a space (" ") character.
                    date_string = month + " " + day + ", " + year;
                }
            }
            else if ((month.Length > 0) && (day.Length > 0))
            {
                // use the month and day parts if the year is missing

                // check if the month part contains all characters and the day part contains all digits
                string month_expression = @"[a-zA-Z]{" + month.Length + "}";
                string day_expression = @"\d{" + day.Length + "}";

                if ((Regex.IsMatch(month, month_expression)) && (Regex.IsMatch(day, day_expression)))
                {
                    // the month part is non-numeric and the day part is numeric; separate the date parts with a space (" ") character.
                    date_string = month + " " + day;
                }
                else
                {
                    // the date parts failed the expression; reset the date_string variable.
                    date_string = String.Empty;
                }
            }
            else if (year.Length > 0)
            {
                // use the year part if the other two parts are missing
                //date_string = year;

                // check if there is a month part
                if (month.Length > 0)
                    // use both the month and the year as the date string
                    date_string = month + " " + year;
                else
                    // use only the year value as the date string
                    date_string = year;
            }
            else
                date_string = String.Empty;

            // copy the date_string value to the bib package field
            Package.Bib_Info.Origin_Info.Date_Issued = date_string;
        }