Možnost náhledu a výběru na další dny v týdnu
This commit is contained in:
@@ -22,8 +22,19 @@ export function getHumanTime(time: Date) {
|
||||
return `${currentHours}:${currentMinutes}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Vrátí index dne v týdnu, kde pondělí=0, neděle=6
|
||||
*
|
||||
* @param date datum
|
||||
* @returns index dne v týdnu
|
||||
*/
|
||||
export const getDayOfWeekIndex = (date: Date) => {
|
||||
// https://stackoverflow.com/a/4467559
|
||||
return (((date.getDay() - 1) % 7) + 7) % 7;
|
||||
}
|
||||
|
||||
/** 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'
|
||||
const index = getDayOfWeekIndex(date);
|
||||
return index == 5 || index == 6;
|
||||
}
|
||||
Reference in New Issue
Block a user