This commit is contained in:
@@ -8,7 +8,7 @@ export function formatDate(date: Date, format?: string) {
|
||||
let month = String(date.getMonth() + 1).padStart(2, "0");
|
||||
let year = String(date.getFullYear());
|
||||
|
||||
const f = (format === undefined) ? 'YYYY-MM-DD' : format;
|
||||
const f = format ?? 'YYYY-MM-DD';
|
||||
return f.replace('DD', day).replace('MM', month).replace('YYYY', year);
|
||||
}
|
||||
|
||||
@@ -61,10 +61,10 @@ export function getLastWorkDayOfWeek(date: Date) {
|
||||
|
||||
/** Vrátí pořadové číslo týdne předaného data v roce dle ISO 8601. */
|
||||
export function getWeekNumber(inputDate: Date) {
|
||||
var date = new Date(inputDate.getTime());
|
||||
const date = new Date(inputDate.getTime());
|
||||
date.setHours(0, 0, 0, 0);
|
||||
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
|
||||
var week1 = new Date(date.getFullYear(), 0, 4);
|
||||
const week1 = new Date(date.getFullYear(), 0, 4);
|
||||
return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000 - 3 + (week1.getDay() + 6) % 7) / 7);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user