void DiffTime(int minutes) { const string DIGIT = @"\d+"; Regex r = new Regex(DIGIT); int NewTime; if (minutes > Properties.Settings.Default.RealtimeTimerGoalMinutes) { throw new InvalidOperationException("do not substract equal or bigger minute value"); } else if (minutes == Properties.Settings.Default.RealtimeTimerGoalMinutes) { NewTime = 1; } else { NewTime = Properties.Settings.Default.RealtimeTimerGoalMinutes - minutes; } Match m = r.Match(textBox1.Lines[0]); if (m.Success) { string NewLine = r.Replace(textBox1.Lines[0], NewTime.ToString()); textBox1.Select(0, textBox1.Lines[0].Length); textBox1.SelectedText = NewLine; } else { textBox1.Select(0, textBox1.Lines[0].Length); textBox1.SelectedText = textBox1.Lines[0] + " " + NewTime.ToString(); } }
// will take time and add 1/2 hour to out time, or remove 1/2 hour from output time private string updateTime(string Update, string strTime) { TimeSpan NewTime; if (Update == "out") { NewTime = Convert.ToDateTime(strTime).AddMinutes(60).TimeOfDay; } else { NewTime = Convert.ToDateTime(strTime).AddMinutes(-60).TimeOfDay; } string strOutput = NewTime.ToString("hh\\:mm"); strOutput = DateTime.ParseExact(strOutput, "HH:mm", null).ToString("hh:mm tt", CultureInfo.GetCultureInfo("en-US")); return(strOutput); }
public override string ToString() => NewTime.ToString();