diff --git a/client/src/Utils.tsx b/client/src/Utils.tsx index cb7b793..7b89f51 100644 --- a/client/src/Utils.tsx +++ b/client/src/Utils.tsx @@ -1,3 +1,5 @@ +import {DepartureTime} from "../../types"; + const TOKEN_KEY = "token"; /** @@ -43,3 +45,15 @@ export function getHumanDateTime(datetime: Date) { return `${day}.${month}.${year} ${hours}:${minutes}`; } } + +/** + * Vrátí true, pokud je předaný čas větší než aktuální čas. + */ +export function isInTheFuture(time: DepartureTime) { + const now = new Date(); + const currentHours = now.getHours(); + const currentMinutes = now.getMinutes(); + const [hours, minutes] = time.split(':').map(Number); + return hours > currentHours || (hours === currentHours && minutes > currentMinutes); +} +