Odfiltrovat ze selectboxu pro výběr preferovaného odchodu časy z minulosti

This commit is contained in:
Michal Hájek 2025-01-15 00:34:47 +01:00
parent 1d995faf8e
commit fe9cee3a80

View File

@ -1,3 +1,5 @@
import {DepartureTime} from "../../types";
const TOKEN_KEY = "token"; const TOKEN_KEY = "token";
/** /**
@ -43,3 +45,15 @@ export function getHumanDateTime(datetime: Date) {
return `${day}.${month}.${year} ${hours}:${minutes}`; 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);
}