The SysUtils standard module from Delphi VCL declares the TDateTime data type. In fact, it is equivalent to a double precision floating point number. In its whole part the day is stored, in the fractional part - the time of the day as a fractional part of the day, considering the day as a unit. Similar to the TDateTime datatype in the VCL (the SysUtils module),
KOL introduces its own TDateTime datatype. With the difference that if SysUtils.TDateTime as a floating point number counts in its integer part the days from December 31, 1899, in KOL.TDateTime the countdown starts from January 1, 1 AD (era "from the birth of Christ") - by Gregorian calendar. I did this because I think this data type is convenient not only for communicating with SQL servers, the developers of the standards for which decided that before the 20th century there was nothing that could be counted.
If someone needs compatibility with SysUtils.TDatetime, then to convert from a KOL date to a VCL, it is enough to add the VCLDate0 constant (equal to 693 594, i.e. the number of days from January 1, 1 to December 31, 1899) , and for the reverse transformation, subtract the same constant. For conversion convenience, such a constant is declared in KOL under the name VCLDate0.
The set of functions for working with dates and times is slightly different from that of SysUtils:
Now - returns the current system date and time;
Date - returns today's date (discarding the time);
DecodeDate(d, Y, M, D ) - decodes the date;
DecodeDateFully(d, Y, M, DW, D) - decodes the date (and day of the week);
DayOfWeek(D) - decodes only the day of the week;
EncodeDate(Y, M, D, T) - encodes date and time;
SystemTime2DateTime(ST, D) - converts the TSystemTime structure to TDateTime;
DateTime2SystemTime(D, ST) - performs the inverse transformation;
Date2StrFmt(s, D) - formats the date into a string;
Time2StrFmt(s, D) - formats the time into a string;
DateTime2StrShort(D) - formats the date into a string using the default short system format;
Str2DateTimeFmt(s1, s2) - reads the date and time from the string according to the specified format;
Str2DateTimeShort(s ) - similar to the previous function, but the system default format is used;
Str2DateTimeShortEx(s ) - in addition to the previous function, uses separators (depending on the regional settings of the system) so as not to confuse the date with the time.
In addition to working with the TDateTime type, KOL has a number of functions for working with the TSystemTime structure directly through the API (floating point numbers are not used in this case):
CompareSystemTime(ST1, ST2) - compares two dates (structures of type TSystemTime), and returns -1, 0, or 1, depending on the result of the comparison;
IncDays(ST, n) - increases the date by the specified number of days (if n <0, then decreases);
IncMonths(ST, n) - increases the date by the specified number of months (for n <0, it decreases);
SystemDate2Str(ST, localeID, dfltDateFmt, s) - formats the date in accordance with the specified parameters;
SystemTime2Str(ST, localeID, flgs, s) - formats the time in accordance with the specified parameters.