olegy123 писал(а):Все помогли.
думаю во что паковать время.. Double нравится.
TDateTime:
- Код: Выделить всё
TDateTime = type Double;
TDate = type TDateTime;
TTime = type TDateTime;
Лазарус сам упаковывает дату и время в Double.
См. функции:
Function TryEncodeDate(Year,Month,Day : Word; Out Date : TDateTime) : Boolean;
function TryEncodeTime(Hour, Min, Sec, MSec:word; Out Time : TDateTime) : boolean;
- Код: Выделить всё
Function TryEncodeDate(Year,Month,Day : Word; Out Date : TDateTime) : Boolean;
var
c, ya: cardinal;
begin
Result:=(Year>0) and (Year<10000) and
(Month in [1..12]) and
(Day>0) and (Day<=MonthDays[IsleapYear(Year),Month]);
If Result then
begin
if month > 2 then
Dec(Month,3)
else
begin
Inc(Month,9);
Dec(Year);
end;
c:= Year DIV 100;
ya:= Year - 100*c;
Date := (146097*c) SHR 2 + (1461*ya) SHR 2 + (153*cardinal(Month)+2) DIV 5 + cardinal(Day);
// Note that this line can't be part of the line above, since TDateTime is
// signed and c and ya are not
Date := Date - 693900;
end
end;
function TryEncodeTime(Hour, Min, Sec, MSec:word; Out Time : TDateTime) : boolean;
begin
Result:=(Hour<24) and (Min<60) and (Sec<60) and (MSec<1000);
If Result then
Time:=TDateTime(cardinal(Hour)*3600000+cardinal(Min)*60000+cardinal(Sec)*1000+MSec)/MSecsPerDay;
end;