Skip to content

Commit

Permalink
Remove helper conversion functions in favor of native JS Date utils.
Browse files Browse the repository at this point in the history
  • Loading branch information
emmiegit committed Oct 7, 2024
1 parent 17bf3b5 commit cc0a6ae
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 36 deletions.
3 changes: 1 addition & 2 deletions framerail/src/lib/server/load/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = {
Expand Down
30 changes: 0 additions & 30 deletions framerail/src/lib/utils.ts

This file was deleted.

3 changes: 1 addition & 2 deletions framerail/src/routes/+error.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -181,7 +180,7 @@ as soon as we can figure out prettier support for it.
>{(deletedPage.rating > 0 ? "+" : "") + deletedPage.rating}</span
>) - {$page.error.internationalization?.["wiki-page-deleted"].replace(
"{$datetime}",
parseDate(deletedPage.page_deleted_at).toLocaleString()
new Date(deletedPage.page_deleted_at).toLocaleString()
)}
</label>
<br />
Expand Down
3 changes: 1 addition & 2 deletions framerail/src/routes/[slug]/[...extra]/page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -703,7 +702,7 @@
]}
</div>
<div class="revision-attribute created-at">
{parseDate(revisionItem.created_at).toLocaleString()}
{new Date(revisionItem.created_at).toLocaleString()}
</div>
<div class="revision-attribute user">
{revisionItem.user_id}
Expand Down

0 comments on commit cc0a6ae

Please sign in to comment.