Translate

Mittwoch, 8. November 2017

C# check if a Time/ TimeSpan goes over one day


private bool CheckTimeSpanOverDay(TimeSpan selectedTime, TimeSpan from, TimeSpan to)
        {
            if (from <= to)
            {
                // Start and stop times are in the same day
                if (selectedTime >= from && selectedTime <= to)
                {
                    return true;
                }
            }
            else
            {
                // Start and stop times are in different days
                if (selectedTime >= from || selectedTime <= to)
                {
                    return true;
                }
            }
            return false;
        }

Keine Kommentare:

Kommentar veröffentlichen