What is the purpose of having Date
and Time
classes when there is a DateTime
class that can handle both?
Another way of thinking of this is that Date
and DateTime
model time in terms of clocks and calendars, which is useful for describing times to users, and scheduling events. Having a Date
without a time is nice for when you don't care about the time, and you don't want to think about time zones.
Time
models time as a continuum, and is a wrapper around the Unix timestamp, which is just an integer. This is useful for all manner of internal applications where the computer doesn't care much whether a calendar boundary has been crossed, but just how many seconds (or milliseconds) have elapsed.