|
116 | 116 | <script lang="ts" setup> |
117 | 117 | import { computed, nextTick, onMounted, onUnmounted, ref, useTemplateRef } from 'vue'; |
118 | 118 | import { unrefElement, useSwipe } from '@vueuse/core'; |
119 | | - import { getISOWeek, getWeek, set, type Day } from 'date-fns'; |
| 119 | + import { getISOWeek, getWeek, set, type Day, startOfWeek, endOfWeek, eachDayOfInterval } from 'date-fns'; |
120 | 120 |
|
121 | 121 | import { useArrowNavigation, useHelperFns, useDateUtils, useContext, useFormatter } from '@/composables'; |
122 | 122 |
|
|
376 | 376 | }; |
377 | 377 |
|
378 | 378 | const getDayNames = (): string[] => { |
379 | | - const daysArray = [1, 2, 3, 4, 5, 6, 7]; |
| 379 | + const now = getDate(); |
| 380 | + const start = startOfWeek(now, { locale: rootProps.locale, weekStartsOn: +rootProps.weekStart as Day }); |
| 381 | + const end = endOfWeek(now, { locale: rootProps.locale, weekStartsOn: +rootProps.weekStart as Day }); |
380 | 382 |
|
381 | | - const days = daysArray.map((day) => formatWeekDay(day)); |
| 383 | + const daysInWeek = eachDayOfInterval({ start, end }); |
382 | 384 |
|
383 | | - const beforeWeekStart = days.slice(0, +rootProps.weekStart); |
384 | | - const afterWeekStart = days.slice(+rootProps.weekStart + 1, days.length); |
385 | | -
|
386 | | - return [days[+rootProps.weekStart]!].concat(...afterWeekStart).concat(...beforeWeekStart); |
| 385 | + return daysInWeek.map((day) => formatWeekDay(day)); |
387 | 386 | }; |
388 | 387 |
|
389 | 388 | defineExpose({ triggerTransition }); |
|
0 commit comments