// clone constructor public DateLimits(DateLimits a) { this.EarliestStartDate = a.EarliestStartDate; this.EarliestEndDate = a.EarliestEndDate; this.LatestStartDate = a.LatestStartDate; this.LatestEndDate = a.LatestEndDate; }
public static DateLimits GetDateFilter(string dateFilter, string fromDate, string toDate) { var fromToDate = new DateLimits(); if (CheckEmpty.Numeric(dateFilter) != (long)Enumerations.DateLimit.Open) { fromToDate = CalculateDate((Enumerations.DateLimit)Convert.ToInt16(dateFilter), DateTime.Now.Date); //if (IsDate(fromToDate.ToDate.ToString(CultureInfo.InvariantCulture))) fromToDate.ToDate = fromToDate.ToDate.AddDays(1); return(fromToDate); } if (CheckEmpty.Numeric(dateFilter) == (long)Enumerations.DateLimit.Open) { var from = ReadDateFromDisplay(fromDate); var to = ReadDateFromDisplay(toDate); fromToDate.FromDate = new DateTime(from.Year, from.Month, from.Day); fromToDate.ToDate = new DateTime(to.Year, to.Month, to.Day); if (IsDate(fromToDate.ToDate.ToString(CultureInfo.InvariantCulture))) { fromToDate.ToDate = fromToDate.ToDate.GetMaxTimeOfDate(); } return(fromToDate); } fromToDate.FromDate = DateTime.MinValue; fromToDate.ToDate = DateTime.MaxValue; return(fromToDate); }
public AnalyserStartupArgs(string path, DateLimits limit, DateTime dateLimit) { Path = path; DateLimit = dateLimit; Limit = limit; // Create the upper and lower limits switch (limit) { case DateLimits.ExactDate: _lowerLimit = new DateTime(DateLimit.Year, DateLimit.Month, DateLimit.Day, 0,0,0,1); _upperLimit = _lowerLimit.AddDays(1).AddSeconds(-1); break; case DateLimits.MonthAndYear: _lowerLimit = new DateTime(DateLimit.Year, DateLimit.Month, 1, 0, 0, 0, 1); _upperLimit = _lowerLimit.AddMonths(1).AddSeconds(-1); break; case DateLimits.Year: _lowerLimit = new DateTime(DateLimit.Year, 1, 1, 0, 0, 0, 1); _upperLimit = _lowerLimit.AddYears(1).AddSeconds(-1); break; } }
private void rbLimitYear_CheckedChanged(object sender, EventArgs e) { if (rbLimitYear.Checked) DateLimit = DateLimits.Year; }
private void rbLimitNoLimits_CheckedChanged(object sender, EventArgs e) { if (rbLimitNoLimits.Checked) DateLimit = DateLimits.NoLimit; }
private void rbLimitMonth_CheckedChanged(object sender, EventArgs e) { if (rbLimitMonth.Checked) DateLimit = DateLimits.MonthAndYear; }
private void rbLimitDate_CheckedChanged(object sender, EventArgs e) { if (rbLimitDate.Checked) DateLimit = DateLimits.ExactDate; }
private void MainForm_Load(object sender, EventArgs e) { // Append the version number to the form title var version = typeof(MainForm).Assembly.GetName().Version; if (version != null) this.Text += $" | v{version}"; DateLimit = DateLimits.NoLimit; }
public DateValidator(DateLimits a) : base(a) { }
public static DateLimits CalculateDate(Enumerations.DateLimit dateLimitVal, DateTime relDate) { var fromToDate = new DateLimits(); //SET STARTING AND ENDING DATES BASED ON THE OPTION SELECTED switch (dateLimitVal) { case Enumerations.DateLimit.Today: { fromToDate.FromDate = relDate; fromToDate.ToDate = relDate; fromToDate.ToDate = fromToDate.ToDate.GetMaxTimeOfDate(); return(fromToDate); } case Enumerations.DateLimit.Yesterday: { fromToDate.FromDate = relDate.AddDays(-1); fromToDate.ToDate = relDate.AddDays(-1); fromToDate.ToDate = fromToDate.ToDate.GetMaxTimeOfDate(); return(fromToDate); } case Enumerations.DateLimit.ThisWeek: { fromToDate.FromDate = relDate.AddDays(-((int)relDate.DayOfWeek - 1)); fromToDate.ToDate = fromToDate.FromDate.AddDays(7 - 1); fromToDate.ToDate = fromToDate.ToDate.GetMaxTimeOfDate(); return(fromToDate); } case Enumerations.DateLimit.PreviousWeek: { fromToDate = CalculateDate(Enumerations.DateLimit.ThisWeek, relDate); fromToDate.FromDate = fromToDate.FromDate.AddDays(-7); fromToDate.ToDate = fromToDate.ToDate.AddDays(-7); fromToDate.ToDate = fromToDate.ToDate.GetMaxTimeOfDate(); return(fromToDate); } case Enumerations.DateLimit.ThisMonth: { fromToDate.FromDate = relDate.AddDays(-relDate.Day); fromToDate.ToDate = fromToDate.FromDate.AddMonths(1); fromToDate.ToDate = fromToDate.ToDate.GetMaxTimeOfDate(); return(fromToDate); } case Enumerations.DateLimit.PreviousMonth: { relDate = new DateTime(relDate.Year, relDate.Month, 1); fromToDate.FromDate = relDate.AddMonths(-1); fromToDate.ToDate = relDate; fromToDate.ToDate = fromToDate.ToDate.GetMaxTimeOfDate(); return(fromToDate); } case Enumerations.DateLimit.ThisQuarter: { switch (relDate.Month) { case 1: case 2: case 3: { fromToDate.FromDate = new DateTime(relDate.Year, 1, 1); fromToDate.ToDate = new DateTime(relDate.Year, 4, 1); fromToDate.ToDate = fromToDate.ToDate.GetMaxTimeOfDate(); return(fromToDate); } case 4: case 5: case 6: { fromToDate.FromDate = new DateTime(relDate.Year, 4, 1); fromToDate.ToDate = new DateTime(relDate.Year, 7, 1); fromToDate.ToDate = fromToDate.ToDate.GetMaxTimeOfDate(); return(fromToDate); } case 7: case 8: case 9: { fromToDate.FromDate = new DateTime(relDate.Year, 7, 1); fromToDate.ToDate = new DateTime(relDate.Year, 10, 1); fromToDate.ToDate = fromToDate.ToDate.GetMaxTimeOfDate(); return(fromToDate); } case 10: case 11: case 12: { fromToDate.FromDate = new DateTime(relDate.Year, 10, 1); fromToDate.ToDate = new DateTime(relDate.Year + 1, 1, 1); fromToDate.ToDate = fromToDate.ToDate.GetMaxTimeOfDate(); return(fromToDate); } } break; } case Enumerations.DateLimit.PreviousQuarter: { fromToDate = CalculateDate(Enumerations.DateLimit.ThisQuarter, relDate); fromToDate.FromDate = fromToDate.FromDate.AddMonths(-3); fromToDate.ToDate = fromToDate.ToDate.AddMonths(-3); fromToDate.ToDate = fromToDate.ToDate.GetMaxTimeOfDate(); return(fromToDate); } case Enumerations.DateLimit.ThisHalfYear: { switch (relDate.Month) { case 1: case 2: case 3: case 4: case 5: case 6: { fromToDate.FromDate = new DateTime(relDate.Year, 1, 1); fromToDate.ToDate = new DateTime(relDate.Year, 7, 1); fromToDate.ToDate = fromToDate.ToDate.GetMaxTimeOfDate(); return(fromToDate); } case 7: case 8: case 9: case 10: case 11: case 12: { fromToDate.FromDate = new DateTime(relDate.Year, 7, 1); fromToDate.ToDate = new DateTime(relDate.Year + 1, 1, 1); fromToDate.ToDate = fromToDate.ToDate.GetMaxTimeOfDate(); return(fromToDate); } } break; } case Enumerations.DateLimit.PreviousHalfYear: { fromToDate = CalculateDate(Enumerations.DateLimit.ThisHalfYear, relDate); fromToDate.FromDate = fromToDate.FromDate.AddMonths(-6); fromToDate.ToDate = fromToDate.ToDate.AddMonths(-6); fromToDate.ToDate = fromToDate.ToDate.GetMaxTimeOfDate(); return(fromToDate); } case Enumerations.DateLimit.ThisYear: { relDate = new DateTime(relDate.Year, 1, 1); fromToDate.FromDate = relDate; fromToDate.ToDate = relDate.AddYears(1); fromToDate.ToDate = fromToDate.ToDate.GetMaxTimeOfDate(); return(fromToDate); } case Enumerations.DateLimit.PreviousYear: { relDate = new DateTime(relDate.Year, 1, 1); fromToDate.FromDate = relDate.AddYears(-1); fromToDate.ToDate = relDate.AddDays(-1); fromToDate.ToDate = fromToDate.ToDate.GetMaxTimeOfDate(); return(fromToDate); } } //TAKE DATE PART ONLY fromToDate.FromDate = fromToDate.FromDate.Date; fromToDate.ToDate = fromToDate.ToDate.Date; return(fromToDate); }