Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function TimeToInt(Value: TDayTime): Integer;
- begin
- {
- if Value.h > 23 then Value.h := 23 else if Value.h < 0 then Value.h := 0;
- if Value.m > 59 then Value.h := 59 else if Value.m < 0 then Value.m := 0;
- if Value.s > 59 then Value.h := 59 else if Value.s < 0 then Value.s := 0;
- if Value.ms > 999 then Value.h := 999 else if Value.ms < 0 then Value.ms := 0;
- if Value.d > 7 then Value.d := 7 else if Value.d < 0 then Value.d := 0;
- }
- Result:= (Value.h shl 26)
- or (Value.m shl 20)
- or (Value.s shl 14)
- or (Value.ms shl 3)
- or (Value.d);
- end;
- function IntToTime(Value: Integer): TDayTime;
- begin
- Result.h := Value shr 26;
- Result.m := Value shr 20 and $3F; // $3F = 111111
- Result.s := Value shr 14 and $3F;
- Result.ms := Value shr 3 and $7FF; // $7FF = 11111111 111
- Result.d := Value and $7; // $7 = 111
- end
Advertisement
Add Comment
Please, Sign In to add comment