when looking in System.pas there TDate und TDateTime defined as the following:
TDateTime = type Double;
TDate = type TDateTime;
TTime = type TDateTime;
obviously TDate and TDateTime are the same.
I just struggled working with TDate and TDateTime bacause I expected that TDate only contains the date-part and not also the time-part.
Now I'm wondering: What the sense behind this? When I declare a variable as TDate, then It should contain a date, and not a dat and a time-value.
They are not the same. If the declarations had been
they had been the same. With the additional
type
, although they are still technically the same, i.e., they are stilldouble
s, they can be told apart. This, for instance, makes it possible to use different property editors in the Object Inspector for the two types (a date picker and a time picker, respectively), while you may use a 'date-time' picker forTDateTime
.In addition, even if it weren't for this, it might be good to use different 'aliases' for different purposes. This might make your source code easier to understand. For instance, if you do
then you know that
StartTime
contains only information about the date, and not the time (unless you abuse the norms).