-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Description
Rationale
Today, we have a DateTime struct in System that represents a specific date and time, which supports time zones. We also have a TimeSpan object that represents a duration (for example the time between two DateTime). I feel that we are missing a simple Time object that represents a time of day, without it being linked to a particular day.
There are a lot of reasons for representing time without dates. Alarms of an alarm clock, work shifts in a company, etc. T-Sql has a time type that cannot today be mapped to a type in .Net.
DateTime.TimeOfDay today returns a TimeSpan, but it feels out of place, TimeSpan represents a duration and not a specific time of day.
Implementation
Implementation would be pretty simple, it would have properties Hours, Minutes, Seconds, Milliseconds, Ticks and a few comparison / transformation methods.
DateTime.TimeOfDay would return this new Time struct instead of the current TimeSpan.