BugInTheSYS

TDateTime/Int-Converting

Oct 26th, 2011
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.42 KB | None | 0 0
  1. function TimeToInt(Value: TDateTime): Integer;
  2. begin
  3.   Result:= (HourOf(Value) shl 26)
  4.         or (MinuteOf(Value) shl 20)
  5.         or (SecondOf(Value) shl 14 )
  6.         or (MilliSecondOf(Value));
  7. end;
  8.  
  9. function IntToTime(Value: Integer): TDateTime;
  10. var h,m,s,ms: Integer;
  11. begin
  12.   h := Value shr 26;
  13.   m := Value shr 20 and $3F;
  14.   s := Value shr 14 and $3F;
  15.   ms := Value and $3FFF;
  16.   Result:=EncodeTime(h,m,s,ms);
  17. end
Advertisement
Add Comment
Please, Sign In to add comment