Podpora víkendů
This commit is contained in:
@@ -6,12 +6,17 @@ export function getDate() {
|
||||
return `${currentYear}-${currentMonth}-${currentDay}`;
|
||||
}
|
||||
|
||||
/** Vrátí human-readable reprezentaci dnešního data pro zobrazení. */
|
||||
export function getTodayString() {
|
||||
const date = new Date();
|
||||
/** Vrátí human-readable reprezentaci předaného data pro zobrazení. */
|
||||
export function getHumanDate(date: Date) {
|
||||
let currentDay = String(date.getDate()).padStart(2, '0');
|
||||
let currentMonth = String(date.getMonth() + 1).padStart(2, "0");
|
||||
let currentYear = date.getFullYear();
|
||||
let currentDayOfWeek = date.toLocaleDateString("CZ-cs", { weekday: 'long' });
|
||||
return `${currentDay}.${currentMonth}.${currentYear} (${currentDayOfWeek})`;
|
||||
}
|
||||
|
||||
/** Vrátí true, pokud je předané datum o víkendu. */
|
||||
export function getIsWeekend(date: Date) {
|
||||
const dayName = date.toLocaleDateString("CZ-cs", { weekday: 'long' }).toLowerCase()
|
||||
return dayName === 'sobota' || dayName === 'neděle'
|
||||
}
|
||||
Reference in New Issue
Block a user