diff --git a/client/src/App.tsx b/client/src/App.tsx index 4ed696b..ba23c97 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -359,9 +359,7 @@ function App() { Poslední změny: {dayIndex != null && diff --git a/client/src/Utils.tsx b/client/src/Utils.tsx index e60e9f2..b7b8315 100644 --- a/client/src/Utils.tsx +++ b/client/src/Utils.tsx @@ -39,12 +39,19 @@ export const deleteToken = () => { /** * Vrátí human-readable reprezentaci předaného data a času pro zobrazení. + * Příklady: + * - dnes 10:52 + * - 10.05.2023 10:52 */ export function getHumanDateTime(datetime: Date) { - let currentDay = String(datetime.getDate()).padStart(2, '0'); - let currentMonth = String(datetime.getMonth() + 1).padStart(2, "0"); - let currentYear = datetime.getFullYear(); - let currentHours = String(datetime.getHours()).padStart(2, '0'); - let currentMinutes = String(datetime.getMinutes()).padStart(2, "0"); - return `${currentDay}.${currentMonth}.${currentYear} ${currentHours}:${currentMinutes}`; + let hours = String(datetime.getHours()).padStart(2, '0'); + let minutes = String(datetime.getMinutes()).padStart(2, "0"); + if (new Date().toDateString() === datetime.toDateString()) { + return `dnes ${hours}:${minutes}`; + } else { + let day = String(datetime.getDate()).padStart(2, '0'); + let month = String(datetime.getMonth() + 1).padStart(2, "0"); + let year = datetime.getFullYear(); + return `${day}.${month}.${year} ${hours}:${minutes}`; + } }