From fe9cee3a8041496e2c4d23e9255d13d604df05c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20H=C3=A1jek?= Date: Wed, 15 Jan 2025 00:34:47 +0100 Subject: [PATCH] =?UTF-8?q?Odfiltrovat=20ze=20selectboxu=20pro=20v=C3=BDb?= =?UTF-8?q?=C4=9Br=20preferovan=C3=A9ho=20odchodu=20=C4=8Dasy=20z=20minulo?= =?UTF-8?q?sti?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/Utils.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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); +} +