/// <summary> /// Searches the collection for the given CDSTDatePair and returns the index. /// If the item is not found in the collection then an ArgumentException /// will be thrown /// </summary> /// <param name="intYear"> /// The year to search for /// </param> /// <returns> /// The index of the CDSTDatePair /// </returns> /// <example> /// <code> /// CDSTDatePairCollection coll = new CDSTDatePairCollection(); /// CDSTDatePair temp = new CDSTDatePair(new DateTime(2006,4,4), new DateTime(2006,10,29)); /// coll.Add(temp); /// int intIndex = coll.SearchYear(temp.Year); /// </code> /// </example> /// Revision History /// MM/DD/YY who Version Issue# Description /// -------- --- ------- ------ --------------------------------------- /// 03/03/06 rrr N/A N/A Creation of class public int FindYear(int intYear) { //Go through the collection checking for matches and return the index //when one is found for (int intIterate = 0; intIterate < InnerList.Count; intIterate++) { CDSTDatePair objYear = (CDSTDatePair)InnerList[intIterate]; if (objYear.ToDate.Year == intYear) { return(intIterate); } } //If the item was not found then throw an error throw new ArgumentException("The given CDSTDatePair is not in the Collection", "int intYear"); }
/// <summary> /// This method indicates whether the given dstDate pair is compliant with the Energy /// Policy Act of 2005 /// </summary> /// <param name="dstDates">A single pair of DST dates</param> /// <returns>True if the both the To DST date and the From DST date comply with the /// Energy Policy Act of 2005, False is returned if either date differs from the Act's mandate. /// A value of True will be returned for all DST date pairs prior to 2007 /// </returns> /// <remarks> /// MM/DD/YY who Version Issue# Description /// -------- --- ------- ------ ------------------------------------------- /// 01/15/07 MAH 8.00.00 Created /// </remarks> static public Boolean EPACompliant(CDSTDatePair dstDates) { Boolean boolCompliant = true; //innocent until proven guilty // The EPA Act of 2005 is not concerned with DST dates prior to 2007 therefore we will // simply say that all dates prior to 2007 are compliant if (dstDates.FromDate.Year >= 2007) { // Start by creating the EPA dates for the current year // The energy policy act calls for the to DST date to occur on the second Sunday in March. // In order to find the date, set the calendar to March 8th, if it doesn't fall on a Sunday, and add a day until // we finally reach a Sunday. DateTime dateEPAToDST = new DateTime(dstDates.FromDate.Year, 3, 8); while (dateEPAToDST.DayOfWeek != DayOfWeek.Sunday) { dateEPAToDST = dateEPAToDST.AddDays(1); } // The from DST date will occur on the first Sunday in November. In this case set the calendar to // March 1st and keep adding days until we reach the first Sunday DateTime dateEPAFromDST = new DateTime(dstDates.ToDate.Year, 11, 1); while (dateEPAFromDST.DayOfWeek != DayOfWeek.Sunday) { dateEPAFromDST = dateEPAFromDST.AddDays(1); } boolCompliant = (dateEPAToDST.Month == dstDates.ToDate.Month) && (dateEPAToDST.Day == dstDates.ToDate.Day) && (dateEPAFromDST.Month == dstDates.FromDate.Month) && (dateEPAFromDST.Day == dstDates.FromDate.Day); } return(boolCompliant); }
/// <summary> /// Adds a CDSTDatePair to the end of the CDSTDatePairCollection /// </summary> /// <param name="objToAdd"> /// The CDSTDatePair to be added /// </param> /// <returns> /// The zero base index of the CDSTDatePair added /// </returns> /// <example> /// <code> /// CDSTDatePairCollection coll = new CDSTDatePairCollection(); /// coll.Add(new CDSTDatePair(new DateTime(2006,4,4), new DateTime(2006,10,29))); /// </code> /// </example> /// Revision History /// MM/DD/YY who Version Issue# Description /// -------- --- ------- ------ --------------------------------------- /// 03/03/06 rrr N/A N/A Creation of class public int Add(CDSTDatePair objToAdd) { return(InnerList.Add(objToAdd)); }
/// <summary> /// Adds a CDSTDatePair to the CDSTDatePairCollection at the given index /// </summary> /// <param name="intIndex"> /// Index to insert the CDSTDatePair into in the collection /// </param> /// <param name="objToAdd"> /// The CDSTDatePair to be added /// </param> /// <example> /// <code> /// CDSTDatePairCollection coll = new CDSTDatePairCollection(); /// coll.Insert(3, new CDSTDatePair(new DateTime(2006,4,4), new DateTime(2006,10,29))); /// </code> /// </example> /// Revision History /// MM/DD/YY who Version Issue# Description /// -------- --- ------- ------ --------------------------------------- /// 03/03/06 rrr N/A N/A Creation of class public void Insert(int intIndex, CDSTDatePair objToAdd) { InnerList.Insert(intIndex, objToAdd); }
/// <summary> /// Method that allows to CDSTDatePair objects to be compared /// </summary> /// <param name="obj"> /// The object to compare the current CDSTDatePair too /// </param> /// <returns> /// An int that tells if objects are equal, less than, or greater than /// </returns> /// <remarks> /// Revision History /// MM/DD/YY who Version Issue# Description /// -------- --- ------- ------ --------------------------------------- /// 03/03/06 rrr N/A N/A Creation of class /// </remarks> public int CompareTo(object obj) { CDSTDatePair objCompare = (CDSTDatePair)obj; return(this.ToDate.Year.CompareTo(objCompare.ToDate.Year)); }