Ejemplo n.º 1
0
        /// <summary>
        /// Check whether dates have the same value of both year and month
        /// </summary>
        private void PerformIdentityChecks()
        {
            int year  = ListOfSetOfDates.First().DateComponents.Year;
            int month = ListOfSetOfDates.First().DateComponents.Month;

            IsYearTheSame  = ListOfSetOfDates.All(date => date.DateComponents.Year == year);
            IsMonthTheSame = ListOfSetOfDates.All(date => date.DateComponents.Month == month);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Return string containing a hyphen and a second date. There is only
 /// one possibility of displaying this date. "BC" is added when the latter date is in previous era
 /// </summary>
 /// <returns>String containing a hyphen and a second date also "BC" is added when needed</returns>
 private string DisplaySecondPart()
 {
     if (ListOfSetOfDates.Last().DateComponents.Year < 0)
     {
         return(" - " + ListOfSetOfDates.Last().DateComponentsAsStrings.Day + "."
                + ListOfSetOfDates.Last().DateComponentsAsStrings.Month + "."
                + ListOfSetOfDates.Last().DateComponentsAsStrings.Year + " BC");
     }
     else
     {
         return(" - " + ListOfSetOfDates.Last().DateComponentsAsStrings.Day + "."
                + ListOfSetOfDates.Last().DateComponentsAsStrings.Month + "."
                + ListOfSetOfDates.Last().DateComponentsAsStrings.Year);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Change order of the dates in the list when needed. Ordering will be
        /// performed by only one component of the date
        /// </summary>
        public void OrderDates()
        {
            PerformIdentityChecks();

            // Order by year when year is not the same in both of the dates
            if (!IsYearTheSame)
            {
                ListOfSetOfDates = ListOfSetOfDates.OrderBy(date => date.DateComponents.Year).ToList();
                return;
            }

            // Order by month when month is not the same in both of the dates
            if (!IsMonthTheSame)
            {
                ListOfSetOfDates = ListOfSetOfDates.OrderBy(date => date.DateComponents.Month).ToList();
                return;
            }

            // Order by day when day is not the same in both of the dates
            ListOfSetOfDates = ListOfSetOfDates.OrderBy(date => date.DateComponents.Day).ToList();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Displaying first date is the tricky part. There are three possibilties
        /// of displaying this date depending on the range between two dates
        /// </summary>
        /// <param name="displayPermissions">DisplayPermissions object holds
        /// all the necessary data to return proper string</param>
        /// <returns>Properly formatted string when DisplayPermissions object cointains
        /// correct data, empty otherwise</returns>
        private string ReturnFirstDate(DisplayPermissions displayPermissions)
        {
            if (displayPermissions == DisplayPermissions.Day)
            {
                return(ListOfSetOfDates.First().DateComponentsAsStrings.Day);
            }

            if (displayPermissions == (DisplayPermissions.Day | DisplayPermissions.Month))
            {
                return(ListOfSetOfDates.First().DateComponentsAsStrings.Day + "."
                       + ListOfSetOfDates.First().DateComponentsAsStrings.Month);
            }

            if (displayPermissions == (DisplayPermissions.Day
                                       | DisplayPermissions.Month | DisplayPermissions.Year))
            {
                return(ListOfSetOfDates.First().DateComponentsAsStrings.Day + "."
                       + ListOfSetOfDates.First().DateComponentsAsStrings.Month + "."
                       + ListOfSetOfDates.First().DateComponentsAsStrings.Year);
            }

            return(String.Empty);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Add a single Date object to the list
 /// </summary>
 /// <param name="date">Date object which was previously validated</param>
 public void Add(Date date)
 {
     ListOfSetOfDates.Add(date);
 }