From f1dce88dabe9bffe997f6168d4db274355342274 Mon Sep 17 00:00:00 2001 From: Gregor Vostrak Date: Wed, 21 May 2025 12:34:02 -0700 Subject: [PATCH] fix time zone issue in daterangepicker --- .../packages/ui/src/Input/DateRangePicker.vue | 38 +++++++++++++------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/resources/js/packages/ui/src/Input/DateRangePicker.vue b/resources/js/packages/ui/src/Input/DateRangePicker.vue index 2ce47efc..d2950695 100644 --- a/resources/js/packages/ui/src/Input/DateRangePicker.vue +++ b/resources/js/packages/ui/src/Input/DateRangePicker.vue @@ -5,10 +5,7 @@ import { PopoverTrigger, } from '@/Components/ui/popover'; import { RangeCalendar } from '@/Components/ui/range-calendar'; -import { - CalendarDate, - getLocalTimeZone, -} from '@internationalized/date'; +import { CalendarDate } from '@internationalized/date'; import { CalendarIcon } from 'lucide-vue-next'; import { computed, ref, inject, type ComputedRef, watch } from 'vue'; import { twMerge } from 'tailwind-merge'; @@ -16,8 +13,9 @@ import { getDayJsInstance, getLocalizedDayJs, } from '@/packages/ui/src/utils/time'; -import { formatDateLocalized } from '@/packages/ui/src/utils/time'; import { type Organization } from '@/packages/api/src'; +import { getUserTimezone } from '@/packages/ui/src/utils/settings'; +import { formatDate } from '@/packages/ui/src/utils/time'; const props = defineProps<{ start: string; @@ -59,12 +57,13 @@ const modelValue = computed({ }), set: (newValue) => { if (newValue.start) { - const date = newValue.start.toDate(getLocalTimeZone()); - emit('update:start', getDayJsInstance()(date).format('YYYY-MM-DD')); + console.log(newValue.start); + const date = newValue.start.toDate(getUserTimezone()); + emit('update:start', getLocalizedDayJs(date.toString()).format()); } if (newValue.end) { - const date = newValue.end.toDate(getLocalTimeZone()); - emit('update:end', getDayJsInstance()(date).format('YYYY-MM-DD')); + const date = newValue.end.toDate(getUserTimezone()); + emit('update:end', getLocalizedDayJs(date.toString()).format()); } }, }); @@ -219,12 +218,27 @@ watch(open, (value) => {