Final fixes for checks in UE2

This commit is contained in:
Ivaylo Ivanov 2021-10-28 20:08:27 +02:00
parent abea7e2d1d
commit c440186462

View File

@ -270,22 +270,23 @@ is_vaccine_fresh g
is_test_fresh :: DreiG_Status -> Kontrollzeitpunkt -> Bool
is_test_fresh g k
| testart g == Antigen = handle_test g k 1
| testart g == PCR = handle_test g k 3
| testart g == Antigen = handle_test g k 24
| testart g == PCR = handle_test g k 72
| otherwise = False
handle_test :: DreiG_Status -> Kontrollzeitpunkt -> Nat1 -> Bool
handle_test g k n
| (calculate_time_diff ((datum g), (uhrzeit g)) k) <= m = True
| (calculate_time_diff ((datum g), (uhrzeit g)) k) > 0 = False
| abs(calculate_time_diff ((datum g), (uhrzeit g)) k) <= m = True
| otherwise = False
where m = toEnum(n * 24 * 60 * 60)
where m = (fromInteger (toInteger (n * 60 * 60))) :: NominalDiffTime
{-
function that calculates the difference in seconds between two datetimes
-}
calculate_time_diff :: (Datum, Uhrzeit) -> (Datum, Uhrzeit) -> NominalDiffTime
calculate_time_diff u1 u2 =
abs(diffUTCTime (convert_to_utc u1) (convert_to_utc u2))
diffUTCTime (convert_to_utc u1) (convert_to_utc u2)
-- Aufgabe A.3