I’m just wondering ..
I have and object like this
public class Entry{
public DateTime? Date { get; set;} // This is just Date
public DateTime? StartTime { get; set; } //This is just Time
public TimeSpan Duration { get; set; } //Time spent on entry
}
Is there a more appropriate type than DateTime or better strategy to handling just Time and Date? Without the pain of having to add a DateTime.MinDate() to all my Start and End Times?
— update —
1 – I like to be able to request if Date or StartTime is Null seperartly on the Entry object.
2 – Entry should allow the user to input Duration without indication of date. Even a default date like DateTime.MinDate() seems like a poor design. (This is why i choose TimeSpan not Start and EndTime)
Don’t split up the date and time components where you store the data. You can provide properties to extract those if you like:
Update:
If you want to have null values for date and time, you can add properties for that without having to split the date and time: