Skip to content

Commit

Permalink
fix: weird date override behaviour (calcom#12292)
Browse files Browse the repository at this point in the history
Co-authored-by: Peer Richelsen <[email protected]>
  • Loading branch information
SomayChauhan and PeerRich authored Nov 16, 2023
1 parent 28acbe5 commit 57a6540
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions packages/features/schedules/components/DateOverrideInputDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,22 @@ const DateOverrideForm = ({

const form = useForm({
values: {
range: value
? value.map((range) => ({
start: new Date(
dayjs
.utc()
.hour(range.start.getUTCHours())
.minute(range.start.getUTCMinutes())
.second(0)
.format()
),
end: new Date(
dayjs.utc().hour(range.end.getUTCHours()).minute(range.end.getUTCMinutes()).second(0).format()
),
}))
: defaultRanges,
range:
value && value[0].start.valueOf() !== value[0].end.valueOf()
? value.map((range) => ({
start: new Date(
dayjs
.utc()
.hour(range.start.getUTCHours())
.minute(range.start.getUTCMinutes())
.second(0)
.format()
),
end: new Date(
dayjs.utc().hour(range.end.getUTCHours()).minute(range.end.getUTCMinutes()).second(0).format()
),
}))
: defaultRanges,
},
});

Expand Down Expand Up @@ -128,7 +129,7 @@ const DateOverrideForm = ({
? selectedDates.map((date) => {
return {
start: date.utc(true).startOf("day").toDate(),
end: date.utc(true).startOf("day").add(1, "day").toDate(),
end: date.utc(true).startOf("day").toDate(),
};
})
: datesInRanges
Expand Down

0 comments on commit 57a6540

Please sign in to comment.