diff --git a/framerail/src/lib/server/load/page.ts b/framerail/src/lib/server/load/page.ts index 104d81b8b6..4a155dc404 100644 --- a/framerail/src/lib/server/load/page.ts +++ b/framerail/src/lib/server/load/page.ts @@ -3,7 +3,6 @@ import { parseAcceptLangHeader } from "$lib/locales" import { translate } from "$lib/server/deepwell/translate" import { pageView } from "$lib/server/deepwell/views" import type { Optional, TranslateKeys } from "$lib/types" -import { parseDateEpoch } from "$lib/utils" import { error, redirect } from "@sveltejs/kit" // TODO form single deepwell request that does all the relevant prep stuff here @@ -80,7 +79,7 @@ export async function loadPage( if (errorStatus === null) { // Calculate difference of days since latest page edit - let updatedAt = parseDateEpoch(viewData.page.updated_at ?? viewData.page.created_at) + let updatedAt = Date.parse(viewData.page.updated_at ?? viewData.page.created_at) let daysDiff = Math.floor((Date.now() - updatedAt) / 1000 / 86400) translateKeys = { diff --git a/framerail/src/lib/utils.ts b/framerail/src/lib/utils.ts deleted file mode 100644 index 43b8a4f9d8..0000000000 --- a/framerail/src/lib/utils.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Convenience function that converts date string format provided by - * Deepwell as `YYYY-MM-DD HH:MM:SS.SSSSSS +HH:MM:SS` into - * `YYYY-MM-DDTHH:mm:ss.sss+HH:mm` - */ -export function convertDateString(dateStr: string): string { - let dateParts = dateStr.split(" ") - let time = dateParts[1].split(".") - let subsec = time.length == 2 ? "." + time[1].slice(0, 3) : "" - let timezone = dateParts[2].split(":") - timezone.pop() - let output = `${dateParts[0]}T${time[0]}${subsec}${timezone.join(":")}` - return output -} - -/** - * Convenience function that converts date string format provided by - * Deepwell as `YYYY-MM-DD HH:MM:SS.SSSSSS +HH:MM:SS` into unix epoch - */ -export function parseDateEpoch(dateStr: string): number { - return Date.parse(convertDateString(dateStr)) -} - -/** - * Convenience function that converts date string format provided by - * Deepwell as `YYYY-MM-DD HH:MM:SS.SSSSSS +HH:MM:SS` into date object - */ -export function parseDate(dateStr: string): Date { - return new Date(convertDateString(dateStr)) -} diff --git a/framerail/src/routes/+error.svelte b/framerail/src/routes/+error.svelte index ab7b14311a..fe46f11485 100644 --- a/framerail/src/routes/+error.svelte +++ b/framerail/src/routes/+error.svelte @@ -3,7 +3,6 @@ import { goto, invalidateAll } from "$app/navigation" import { useErrorPopup } from "$lib/stores" import { Layout } from "$lib/types" - import { parseDate } from "$lib/utils" let showErrorPopup = useErrorPopup() let showRestoreAction = false @@ -181,7 +180,7 @@ as soon as we can figure out prettier support for it. >{(deletedPage.rating > 0 ? "+" : "") + deletedPage.rating}) - {$page.error.internationalization?.["wiki-page-deleted"].replace( "{$datetime}", - parseDate(deletedPage.page_deleted_at).toLocaleString() + new Date(deletedPage.page_deleted_at).toLocaleString() )}
diff --git a/framerail/src/routes/[slug]/[...extra]/page.svelte b/framerail/src/routes/[slug]/[...extra]/page.svelte index d7f248f9c2..4f5863cbbb 100644 --- a/framerail/src/routes/[slug]/[...extra]/page.svelte +++ b/framerail/src/routes/[slug]/[...extra]/page.svelte @@ -4,7 +4,6 @@ import { onMount } from "svelte" import { useErrorPopup } from "$lib/stores" import { Layout } from "$lib/types" - import { parseDate } from "$lib/utils" let showErrorPopup = useErrorPopup() let showMoveAction = false @@ -703,7 +702,7 @@ ]}
- {parseDate(revisionItem.created_at).toLocaleString()} + {new Date(revisionItem.created_at).toLocaleString()}
{revisionItem.user_id}