Skip to main content

Posts

Showing posts with the label DateTime

Finding gaps in time

Let assume that we want to create a simple scheduler which allow user to plan meeting as long as he want with 1 minute precision. There is multiple ways to make such implementation but in this post I want to present an approach I used recently. In my implementation I`ve created separated type which represents any time period. I called it Range and it`s consists of three properties (one is read-only). Main idea behind creating this time is encapsulate state and end date of used defined time period. /// <summary> /// Represents range in time. /// </summary> public class Range { /// <summary> /// Gets or sets represents range start time. /// </summary> public DateTime StartTime { get ; set ; } /// <summary> /// Gets or sets represents range end time. /// </summary> public DateTime EndTime { get ; set ; } /// <summary> /// Gets ra