Ejemplo n.º 1
0
        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }
            DateRange other = (DateRange)obj;

            return(DateUnit.EqualsDateUtil(FromDate, other.FromDate) && DateUnit.EqualsDateUtil(ToDate, other.ToDate));
        }
Ejemplo n.º 2
0
        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }
            DateUnit other = (DateUnit)obj;

            return(Year == other.Year && Month == other.Month && Day == other.Day);
        }
Ejemplo n.º 3
0
 public static bool EqualsDateUtil(DateUnit date1, DateUnit date2)
 {
     if (date1 == null)
     {
         if (date2 == null)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     return(date1.Equals(date2));
 }
Ejemplo n.º 4
0
        public object Clone()
        {
            DateUnit newFromDate = null;
            DateUnit newToDate   = null;

            if (fromDate != null)
            {
                newFromDate = (DateUnit)fromDate.Clone();
            }
            if (toDate != null)
            {
                newToDate = (DateUnit)toDate.Clone();
            }
            return(new DateRange(newFromDate, newToDate));
        }
Ejemplo n.º 5
0
 public static DateRange Parse(string fromDateStr, string toDateStr)
 {
     DateUnit fromDate = null;
     DateUnit toDate = null;
     if (!string.IsNullOrEmpty(fromDateStr))
     {
         fromDate = DateParser.Parse(fromDateStr);
     }
     if (fromDate == null)
     {
         return null;
     }
     if (!string.IsNullOrEmpty(toDateStr))
     {
         toDate = DateParser.Parse(toDateStr);
     }
     if (toDate == null)
     {
         toDate = new DateUnit();
     }
     return new DateRange(fromDate, toDate);
 }
Ejemplo n.º 6
0
 public static string ToString(DateUnit dateUnit)
 {
     if (dateUnit == null)
     {
         return "";
     }
     DateUnitType type = dateUnit.DateUnitType;
     if (type == DateUnitType.YearMonthDay)
     {
         return ToString(dateUnit.Date);
     }
     else if (type == DateUnitType.YearMonth)
     {
         return dateUnit.ToYearMonthString();
     }
     else if (type == DateUnitType.Year)
     {
         return dateUnit.ToYearString();
     }
     return "";
 }
Ejemplo n.º 7
0
 public DateRange(DateUnit fromDate, DateUnit toDate)
 {
     this.fromDate = fromDate;
     this.toDate = toDate;
 }
Ejemplo n.º 8
0
 public DateRange(DateUnit fromDate, DateUnit toDate)
 {
     this.fromDate = fromDate;
     this.toDate   = toDate;
 }
Ejemplo n.º 9
0
 public static bool EqualsDateUtil(DateUnit date1, DateUnit date2)
 {
     if (date1 == null)
     {
         if (date2 == null)
         {
             return true;
         }
         else
         {
             return false;
         }
     }
     return date1.Equals(date2);
 }
Ejemplo n.º 10
0
 private static DateRange ReadDateRange(XElement rootElem, XName dateElemName)
 {
     IEnumerable<XElement> timePrdElems = rootElem.Descendants(dateElemName);
     DateUnit fromDate = new DateUnit();
     DateUnit toDate = new DateUnit();
     foreach (XElement timePrdElem in timePrdElems)
     {
         string dateStr = (string)timePrdElem.Attribute(ATTR_DATE);
         string eventStr = (string)timePrdElem.Attribute(ATTR_EVENT);
         if (eventStr == null || eventStr == "start")
         {
             fromDate = DateParser.Parse(dateStr);
         }
         else if (eventStr == "end")
         {
             toDate = DateParser.Parse(dateStr);
         }
     }
     if (fromDate == null)
     {
         return null;
     }
     return new DateRange(fromDate, toDate);
 }