View difference between Paste ID: VWa8qHY3 and ubNLZfFP
SHOW: | | - or go back to the newest paste.
1-
function TimeToInt(Value: TDateTime): Integer;
1+
    function TimeToInt(Value: TDayTime): Integer;
2-
begin
2+
    begin
3-
  Result:= (HourOf(Value) shl 26)
3+
	  {
4-
        or (MinuteOf(Value) shl 20)
4+
	  if Value.h > 23 then Value.h := 23 else if Value.h < 0 then Value.h := 0;
5-
        or (SecondOf(Value) shl 14 )
5+
	  if Value.m > 59 then Value.h := 59 else if Value.m < 0 then Value.m := 0;
6-
        or (MilliSecondOf(Value));
6+
	  if Value.s > 59 then Value.h := 59 else if Value.s < 0 then Value.s := 0;
7-
end;
7+
	  if Value.ms > 999 then Value.h := 999 else if Value.ms < 0 then Value.ms := 0;
8-
8+
	  if Value.d > 7 then Value.d := 7 else if Value.d < 0 then Value.d := 0;
9-
function IntToTime(Value: Integer): TDateTime;
9+
	  }
10-
var h,m,s,ms: Integer;
10+
      Result:= (Value.h shl 26)
11-
begin
11+
            or (Value.m shl 20)
12-
  h := Value shr 26;
12+
            or (Value.s shl 14)
13-
  m := Value shr 20 and $3F;
13+
            or (Value.ms shl 3)
14-
  s := Value shr 14 and $3F;
14+
			or (Value.d);
15-
  ms := Value and $3FFF;
15+
    end;
16-
  Result:=EncodeTime(h,m,s,ms);
16+
     
17-
end
17+
    function IntToTime(Value: Integer): TDayTime;
18
    begin
19
      Result.h := Value shr 26;
20
      Result.m := Value shr 20 and $3F;   // $3F = 111111
21
      Result.s := Value shr 14 and $3F;
22
      Result.ms := Value shr 3 and $3FFF; // $3FFF = 11111111 111111
23
	  Result.d := Value and $7;           // $7 = 111
24
    end
25