TimeSpan zero = new TimeSpan(0, 0, 0, 0, 0); private void ti_timeLeft_Tick(object sender, EventArgs e) { try { TimeSpan notification1 = new TimeSpan(0, 0, 2, 0, 0); TimeSpan notification2 = new TimeSpan(0, 0, 5, 0, 0); TimeSpan notification3 = new TimeSpan(0, 0, 10, 0, 0); } catch (Exception ex) { } DateTime now = DateTime.Now; List<TimeSpan> diffs = new List<TimeSpan>(7); #region "Monday" if (DateTime.Now.DayOfWeek.ToString() == "Monday") { if (dtp_monday1.Checked) { if ((dtp_monday1.Value - now) > zero) diffs.Add(dtp_monday1.Value - now); } if (dtp_monday2.Checked) { if ((dtp_monday2.Value - now) > zero) diffs.Add(dtp_monday2.Value - now); } if (dtp_monday3.Checked) { if ((dtp_monday3.Value - now) > zero) diffs.Add(dtp_monday3.Value - now); } if (dtp_monday4.Checked) { if ((dtp_monday4.Value - now) > zero) diffs.Add(dtp_monday4.Value - now); } if (dtp_monday5.Checked) { if ((dtp_monday5.Value - now) > zero) diffs.Add(dtp_monday5.Value - now); } if (dtp_monday6.Checked) { if ((dtp_monday6.Value - now) > zero) diffs.Add(dtp_monday6.Value - now); } if (dtp_monday7.Checked) { if ((dtp_monday7.Value - now) > zero) diffs.Add(dtp_monday7.Value - now); } if (diffs.Count == 0) { //this.lab_time_left.Text = ""; return; } diffs.Sort(); TimeSpan min = diffs[0]; TimeSpan max = diffs[diffs.Count - 1]; this.lab_time_left.Text = "Time left: " + min.Hours.ToString("00") + ":" + min.Minutes.ToString("00") + ":" + min.Seconds.ToString("00"); } }
... if (dtp_monday1.Value.CompareTo(now) > 0) { ...
if((dtp_monday1.Value - now).TotalDays > 0) { // Your logic }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)