1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; import isoWeek from 'dayjs/plugin/isoWeek'; import timezone from 'dayjs/plugin/timezone';
dayjs.extend(utc); dayjs.extend(isoWeek); dayjs.extend(timezone);
}}
function getEnhancedUTCWeekRange(date = new Date()) { const base = dayjs(date).utc();
const start = base.startOf('isoWeek'); const end = start.clone().endOf('day').add(6, 'day');
return { start: start.toDate(), end: end.toDate(), isoWeekNumber: base.isoWeek(), isoYear: base.isoWeekYear(), isoRange: `${start.format('YYYY-MM-DDTHH:mm:ss.SSS[Z]')}/${end.format('YYYY-MM-DDTHH:mm:ss.SSS[Z]')}`, days: Array.from({ length: 7 }, (_, i) => start.add(i, 'day').format('YYYY-MM-DD') ) }; }
|