Kod: Tümünü seç
function InTime(_Current,_Start,_End: TTime): Boolean;
var
H, M, S, MS: Word;
ST, ET, CT: TDateTime;
Begin
DecodeTime(_Current, H, M, S, MS);
CT := EncodeDateTime(1982, 7, 30, H, M, S, MS);
DecodeTime(_Start, H, M, S, MS);
ST := EncodeDateTime(1982, 7, 30, H, M, S, MS);
DecodeTime(_End, H, M, S, MS);
ET := EncodeDateTime(1982, 7, 30, H, M, S, MS);
if _Start >= _End then
Begin
ET := IncDay(ET, 1);
if _Current=EncodeTime(0,0,0,0) then CT := IncDay(CT, 1)
else
if _Current<= _End then CT := IncDay(CT, 1);
End else
if _Current=EncodeTime(0,0,0,0) then CT := IncDay(CT, 1)
else
if
(_Current >_Start) and
(_Current<=EncodeTime(23,59,59,999)) then CT := IncDay(CT, 1);
Result := (CT >= ST) and (CT <= ET);
End;
Kod: Tümünü seç
Check: 00:00:00 Start: 22:00:00 End:08:00:00 Result:True
Check: 01:00:00 Start: 22:00:00 End:08:00:00 Result:True
Check: 02:00:00 Start: 22:00:00 End:08:00:00 Result:True
Check: 03:00:00 Start: 22:00:00 End:08:00:00 Result:True
Check: 04:00:00 Start: 22:00:00 End:08:00:00 Result:True
Check: 05:00:00 Start: 22:00:00 End:08:00:00 Result:True
Check: 06:00:00 Start: 22:00:00 End:08:00:00 Result:True
Check: 07:00:00 Start: 22:00:00 End:08:00:00 Result:True
Check: 08:00:00 Start: 22:00:00 End:08:00:00 Result:True
Check: 09:00:00 Start: 22:00:00 End:08:00:00 Result:False
Check: 10:00:00 Start: 22:00:00 End:08:00:00 Result:False
Check: 11:00:00 Start: 22:00:00 End:08:00:00 Result:False
Check: 12:00:00 Start: 22:00:00 End:08:00:00 Result:False
Check: 13:00:00 Start: 22:00:00 End:08:00:00 Result:False
Check: 14:00:00 Start: 22:00:00 End:08:00:00 Result:False
Check: 15:00:00 Start: 22:00:00 End:08:00:00 Result:False
Check: 16:00:00 Start: 22:00:00 End:08:00:00 Result:False
Check: 17:00:00 Start: 22:00:00 End:08:00:00 Result:False
Check: 18:00:00 Start: 22:00:00 End:08:00:00 Result:False
Check: 19:00:00 Start: 22:00:00 End:08:00:00 Result:False
Check: 20:00:00 Start: 22:00:00 End:08:00:00 Result:False
Check: 21:00:00 Start: 22:00:00 End:08:00:00 Result:False
Check: 22:00:00 Start: 22:00:00 End:08:00:00 Result:True
Check: 23:00:00 Start: 22:00:00 End:08:00:00 Result:True