Текущий архив: 2005.12.11;
Скачать: CL | DM;
ВнизDecodeTime missing in KOL Найти похожие ветки
← →
Boguslaw Brandys (2005-04-12 00:19) [0]Hmm... DecodeTime would be useful to obtain difference beetwen two time points divided into count of hours,minutes,seconds,milliseconds.
DecodeDate exists in KOL but not DecodeTime.Why? Maybe someone would give an example ?
← →
thaddy (2005-04-12 19:21) [1]interface
uses windows,kol,kolmath{??};
procedure DecodeTime(const DateTime: TDateTime; var Hour, Min, Sec, MSec: Word);
implementation
const
HoursPerDay = 24;
MinsPerHour = 60;
SecsPerMin = 60;
MSecsPerSec = 1000;
MinsPerDay = HoursPerDay * MinsPerHour;
SecsPerDay = MinsPerDay * SecsPerMin;
MSecsPerDay = SecsPerDay * MSecsPerSec;
FMSecsPerDay: Single = MSecsPerDay;
IMSecsPerDay: Integer = MSecsPerDay;
function DateTimeToTimeStamp(DateTime: TDateTime): TTimeStamp;
asm
PUSH EBX
XOR EBX,EBX
MOV ECX,EAX
FLD DateTime
FMUL [EBX].FMSecsPerDay
SUB ESP,8
FISTP QWORD PTR [ESP]
FWAIT
POP EAX
POP EDX
OR EDX,EDX
JNS @@1
NEG EDX
NEG EAX
SBB EDX,0
DIV [EBX].IMSecsPerDay
NEG EAX
JMP @@2
@@1: DIV [EBX].IMSecsPerDay
@@2: ADD EAX,DateDelta
MOV [ECX].TTimeStamp.Time,EDX
MOV [ECX].TTimeStamp.Date,EAX
POP EBX
end;
procedure DecodeTime(const DateTime: TDateTime; var Hour, Min, Sec, MSec: Word);
var
MinCount, MSecCount: Word;
begin
DivMod(DateTimeToTimeStamp(DateTime).Time, SecsPerMin * MSecsPerSec, MinCount, MSecCount);
DivMod(MinCount, MinsPerHour, Hour, Min);
DivMod(MSecCount, MSecsPerSec, Sec, MSec);
end;
end.
← →
thaddy (2005-04-12 19:25) [2]and forgot:
type
TTimeStamp = record
Time: Integer;
Date: Integer;
end;
const
DateDelta = 693594;
← →
Владимир Кладов (2005-04-12 19:52) [3]var D: TDateTime; S: TSystemTime;
DateTime2SystemTime( D, S );
// S.wHour; S.wMinute; S.wSecond; ?
← →
thaddy (2005-04-12 20:50) [4]Again, there is more in kol than we know.
Thanks Vladimir!
← →
Boguslaw Brandys (2005-04-13 13:05) [5]DateTime2SystemTime work good but I mean DecodeTime in context of decode period between two dates !
var Start,End: TDateTime; S: TSystemTime;
End := Now - Start;
DateTime2SystemTime( End, S );
// S.wHour; S.wMinute; S.wSecond; - bad result now :-(
← →
Владимир Кладов (2005-04-13 16:25) [6]try this:
DateTime2SystemTime( Fraq( D1 - D2 ) + Trunc( Now ), S );
← →
Boguslaw Brandys (2005-04-13 19:04) [7]Where is Fraq defined ?
← →
Владимир Кладов (2005-04-13 20:47) [8]sorry, Frac (fractional part of floating point number). Should be defined in system unit.
Страницы: 1 вся ветка
Текущий архив: 2005.12.11;
Скачать: CL | DM;
Память: 0.46 MB
Время: 0.059 c