mirror of
https://github.com/lukevella/rallly.git
synced 2025-06-20 03:21:47 +02:00
🚑 Fix times showing incorrectly
This was due to times being converted to utc in postgres/prisma.
This commit is contained in:
parent
584575c69e
commit
a47b6f602f
3 changed files with 11 additions and 8 deletions
|
@ -77,9 +77,11 @@ const ManagePoll: React.FunctionComponent<{
|
|||
name="pollOptions"
|
||||
title={poll.title}
|
||||
defaultValues={{
|
||||
navigationDate: poll.options[0].start.toString(),
|
||||
navigationDate: dayjs(poll.options[0].start)
|
||||
.utc()
|
||||
.format("YYYY-MM-DD"),
|
||||
options: poll.options.map((option) => {
|
||||
const start = dayjs(option.start);
|
||||
const start = dayjs(option.start).utc();
|
||||
return option.duration > 0
|
||||
? {
|
||||
type: "timeSlot",
|
||||
|
|
|
@ -102,7 +102,7 @@ export const polls = router({
|
|||
options: {
|
||||
createMany: {
|
||||
data: input.options.map((option) => ({
|
||||
start: new Date(option.startDate),
|
||||
start: new Date(`${option.startDate}Z`),
|
||||
duration: option.endDate
|
||||
? dayjs(option.endDate).diff(
|
||||
dayjs(option.startDate),
|
||||
|
@ -167,13 +167,13 @@ export const polls = router({
|
|||
const [start, end] = optionValue.split("/");
|
||||
if (end) {
|
||||
return {
|
||||
start: new Date(start),
|
||||
start: new Date(`${start}Z`),
|
||||
duration: dayjs(end).diff(dayjs(start), "minute"),
|
||||
pollId,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
start: new Date(start.substring(0, 10) + "T00:00:00"),
|
||||
start: new Date(start.substring(0, 10) + "T00:00:00Z"),
|
||||
pollId,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ export const decodeOptions = (
|
|||
};
|
||||
|
||||
const parseDateOption = (option: Option): ParsedDateOption => {
|
||||
const date = dayjs(option.start);
|
||||
const date = dayjs(option.start).utc();
|
||||
return {
|
||||
type: "date",
|
||||
optionId: option.id,
|
||||
|
@ -101,10 +101,11 @@ const parseTimeSlotOption = (
|
|||
timeZone: string | null,
|
||||
targetTimeZone: string,
|
||||
): ParsedTimeSlotOption => {
|
||||
const start = dayjs(option.start).utc();
|
||||
const startDate =
|
||||
timeZone && targetTimeZone
|
||||
? dayjs(option.start).tz(timeZone, true).tz(targetTimeZone)
|
||||
: dayjs(option.start);
|
||||
? start.tz(timeZone, true).tz(targetTimeZone)
|
||||
: start;
|
||||
|
||||
const endDate = startDate.add(option.duration, "minute");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue