Skip to content

Commit 4a50145

Browse files
committed
fix calendar header timezone issue
1 parent 8aabffd commit 4a50145

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

resources/js/packages/ui/src/FullCalendar/FullCalendarDayHeader.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
import { computed, inject, type ComputedRef } from 'vue';
33
import { formatDate, formatHumanReadableDuration } from '../utils/time';
44
import type { Organization } from '@/packages/api/src';
5+
import type { Dayjs } from 'dayjs';
56
67
const props = defineProps<{
7-
date: Date;
8+
date: Dayjs;
89
totalMinutes?: number;
910
}>();
1011
@@ -20,7 +21,7 @@ const dateFormat = computed(() => organization?.value?.date_format);
2021
<template>
2122
<div class="fc-day-header-custom">
2223
<div class="text-xs text-muted-foreground font-medium">
23-
{{ date.toLocaleDateString('en-US', { weekday: 'short' }) }}
24+
{{ date.format('ddd') }}
2425
</div>
2526
<span>{{ formatDate(date.toISOString(), dateFormat) }}</span>
2627
<span class="block text-xs text-muted-foreground font-medium mt-1">

resources/js/packages/ui/src/FullCalendar/TimeEntryCalendar.vue

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ const calendarOptions = computed(() => ({
250250
editable: true,
251251
eventResizableFromStart: true,
252252
eventDurationEditable: true,
253-
timeZone: 'America/Adak',
253+
timeZone: getUserTimezone(),
254254
eventStartEditable: true,
255255
select: handleDateSelect,
256256
eventClick: handleEventClick,
@@ -332,9 +332,16 @@ watch(showEditTimeEntryModal, (value) => {
332332
</template>
333333
<template #dayHeaderContent="arg">
334334
<FullCalendarDayHeader
335-
:date="arg.date"
335+
:date="
336+
getDayJsInstance()(arg.date.toISOString()).utc().tz(getUserTimezone(), true)
337+
"
336338
:total-minutes="
337-
dailyTotals[getDayJsInstance()(arg.date).format('YYYY-MM-DD')] || 0
339+
dailyTotals[
340+
getDayJsInstance()(arg.date)
341+
.utc()
342+
.tz(getUserTimezone(), true)
343+
.format('YYYY-MM-DD')
344+
] || 0
338345
" />
339346
</template>
340347
</FullCalendar>

0 commit comments

Comments
 (0)