DateTimeCalculator Zeitdifferenz zwischen 2 Terminen

Mit diesem Programm lässt sich ganz einfach die Differenz zwischen 2 Terminen genau anzeigen.

Calculate difference between two events
Calculate difference between two events

Hier die wichtigsten und beinahe einzigen Zeilen Code:

string[] fromTimeSplit = txtFromTime.Text.Split(new string[] { ":" }, StringSplitOptions.None);
string[] tillTimeSplit = txtTillTime.Text.Split(new string[] { ":" }, StringSplitOptions.None);

DateTime fromDate = new DateTime(((DateTime)txtFromDate.SelectedDate).Year, ((DateTime)txtFromDate.SelectedDate).Month, ((DateTime)txtFromDate.SelectedDate).Day, Convert.ToInt32(fromTimeSplit[0]), Convert.ToInt32(fromTimeSplit[1]), Convert.ToInt32(fromTimeSplit[2]));
DateTime tillDate = new DateTime(((DateTime)txtTillDate.SelectedDate).Year, ((DateTime)txtTillDate.SelectedDate).Month, ((DateTime)txtTillDate.SelectedDate).Day, Convert.ToInt32(tillTimeSplit[0]), Convert.ToInt32(tillTimeSplit[1]), Convert.ToInt32(tillTimeSplit[2]));
TimeSpan betweenTime = tillDate - fromDate;

lblResult.Content = betweenTime.Days + " days " + betweenTime.Hours + " hours " + betweenTime.Minutes + " minutes " + betweenTime.Seconds + " seconds";
lblResult.Content += "\nTotal hours: " + Math.Round(betweenTime.TotalHours, 2);
lblResult.Content += "\nTotal minutes: " + Math.Round(betweenTime.TotalMinutes, 2);
lblResult.Content += "\nTotal seconds: " + Math.Round(betweenTime.TotalMinutes, 2);

Dieses Programm ist FREEWARE! Denke doch über eine Spende nach…


Kommentare

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert