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)); }
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); }
public static bool EqualsDateUtil(DateUnit date1, DateUnit date2) { if (date1 == null) { if (date2 == null) { return(true); } else { return(false); } } return(date1.Equals(date2)); }
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)); }
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); }
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 ""; }
public DateRange(DateUnit fromDate, DateUnit toDate) { this.fromDate = fromDate; this.toDate = toDate; }
public DateRange(DateUnit fromDate, DateUnit toDate) { this.fromDate = fromDate; this.toDate = toDate; }
public static bool EqualsDateUtil(DateUnit date1, DateUnit date2) { if (date1 == null) { if (date2 == null) { return true; } else { return false; } } return date1.Equals(date2); }
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); }