Major new version #2
@ -19,7 +19,7 @@ import {
|
||||
getISOWeek,
|
||||
} from '@/utils/date'
|
||||
import { toLocalString, fromLocalString, DEFAULT_TZ } from '@/utils/date'
|
||||
import { addDays, differenceInCalendarDays } from 'date-fns'
|
||||
import { addDays, differenceInCalendarDays, differenceInWeeks } from 'date-fns'
|
||||
import { getHolidayForDate } from '@/utils/holidays'
|
||||
|
||||
const calendarStore = useCalendarStore()
|
||||
@ -52,20 +52,18 @@ const lastTapTime = ref(0)
|
||||
const lastTapDate = ref(null)
|
||||
const DOUBLE_TAP_DELAY = 300 // milliseconds
|
||||
|
||||
const WEEK_MS = 7 * 24 * 60 * 60 * 1000
|
||||
|
||||
const minVirtualWeek = computed(() => {
|
||||
const date = new Date(calendarStore.minYear, 0, 1)
|
||||
const dayOffset = (date.getDay() - calendarStore.config.first_day + 7) % 7
|
||||
const firstDayOfWeek = addDays(date, -dayOffset)
|
||||
return Math.floor((firstDayOfWeek.getTime() - baseDate.value.getTime()) / WEEK_MS)
|
||||
return differenceInWeeks(firstDayOfWeek, baseDate.value)
|
||||
})
|
||||
|
||||
const maxVirtualWeek = computed(() => {
|
||||
const date = new Date(calendarStore.maxYear, 11, 31)
|
||||
const dayOffset = (date.getDay() - calendarStore.config.first_day + 7) % 7
|
||||
const firstDayOfWeek = addDays(date, -dayOffset)
|
||||
return Math.floor((firstDayOfWeek.getTime() - baseDate.value.getTime()) / WEEK_MS)
|
||||
return differenceInWeeks(firstDayOfWeek, baseDate.value)
|
||||
})
|
||||
|
||||
const totalVirtualWeeks = computed(() => {
|
||||
@ -127,7 +125,7 @@ function computeRowHeight() {
|
||||
function getWeekIndex(date) {
|
||||
const dayOffset = (date.getDay() - calendarStore.config.first_day + 7) % 7
|
||||
const firstDayOfWeek = addDays(date, -dayOffset)
|
||||
return Math.floor((firstDayOfWeek.getTime() - baseDate.value.getTime()) / WEEK_MS)
|
||||
return differenceInWeeks(firstDayOfWeek, baseDate.value)
|
||||
}
|
||||
|
||||
function getFirstDayForVirtualWeek(virtualWeek) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user