Custom ISO String function to correct for timezone offsets.

This commit is contained in:
MeowcaTheoRange 2024-04-25 13:33:13 -05:00
parent aa6b18e95c
commit 9cafe2d992

View file

@ -5,6 +5,15 @@ import { useRouter } from "next/navigation";
import { ConditionalNull } from "@/components/utility/Conditional";
import { JSONContentTable, JSONJamTable } from "@/lib/mastoauth/realtypes";
function toIsoString(date:Date) {
return date.getFullYear() +
'-' + (date.getMonth() + 1).toString().padStart(2, "0") +
'-' + (date.getDate()).toString().padStart(2, "0") +
'T' + (date.getHours()).toString().padStart(2, "0") +
':' + (date.getMinutes()).toString().padStart(2, "0") +
':' + (date.getSeconds()).toString().padStart(2, "0");
}
export function Form({jamID, preset}:{jamID:string, preset:{
name: string,
description: string,
@ -15,8 +24,8 @@ export function Form({jamID, preset}:{jamID:string, preset:{
}}) {
const correctPreset = {
...preset,
date_start: new Date(parseInt(preset.date_start)).toISOString().slice(0, -8),
date_end: new Date(parseInt(preset.date_end)).toISOString().slice(0, -8)
date_start: toIsoString(new Date(parseInt(preset.date_start))),
date_end: toIsoString(new Date(parseInt(preset.date_end)))
}
const router = useRouter();
const formik = useFormik({