SHOW:
|
|
- or go back to the newest paste.
| 1 | function TimeToInt(Value: TDayTime): Integer; | |
| 2 | begin | |
| 3 | {
| |
| 4 | if Value.h > 23 then Value.h := 23 else if Value.h < 0 then Value.h := 0; | |
| 5 | if Value.m > 59 then Value.h := 59 else if Value.m < 0 then Value.m := 0; | |
| 6 | if Value.s > 59 then Value.h := 59 else if Value.s < 0 then Value.s := 0; | |
| 7 | if Value.ms > 999 then Value.h := 999 else if Value.ms < 0 then Value.ms := 0; | |
| 8 | if Value.d > 7 then Value.d := 7 else if Value.d < 0 then Value.d := 0; | |
| 9 | } | |
| 10 | Result:= (Value.h shl 26) | |
| 11 | or (Value.m shl 20) | |
| 12 | or (Value.s shl 14) | |
| 13 | or (Value.ms shl 3) | |
| 14 | or (Value.d); | |
| 15 | end; | |
| 16 | ||
| 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 |
| 22 | + | Result.ms := Value shr 3 and $7FF; // $7FF = 11111111 111 |
| 23 | Result.d := Value and $7; // $7 = 111 | |
| 24 | - | end |
| 24 | + | end |
| 25 | ||
| 26 |