Replaced JS Date API with dayjs
All checks were successful
Build and deploy website / build (push) Successful in 56s

This commit is contained in:
2025-02-25 19:49:21 +01:00
parent 16104d12ae
commit 14c65bda05
4 changed files with 19 additions and 5 deletions

View File

@ -1,11 +1,12 @@
---
import * as m from "@/paraglide/messages"
import Layout from "@/layouts/Layout.astro"
import BadgeList from "@/components/badge/BadgeList.astro"
import GiteaLink from "@/components/links/GiteaLink.astro"
import { languageTag } from "@/paraglide/runtime"
import { getEntry, render } from "astro:content"
import { Image } from "astro:assets"
import * as m from "@/paraglide/messages"
import dayjs from "dayjs"
import "@/styles/global.css"
interface Props {
@ -26,9 +27,12 @@ const {
createdAt,
updatedAt,
} = entry!.data
function localeDateString(isoString: string): string {
return dayjs(isoString).locale(languageTag()).format("YYYY-MM-DD")
}
---
<!--TODO day.js / Temporal API for dates?-->
<Layout title={title} class="mx-auto max-w-[750px]">
<div class="flex justify-between my-2">
<div>
@ -37,10 +41,10 @@ const {
</div>
<div class="flex flex-col items-end">
<p>
{m.createdAt()}: {new Date(createdAt).toLocaleDateString(languageTag())}
{m.createdAt()}: {localeDateString(createdAt)}
</p>
<p>
{m.updatedAt()}: {new Date(updatedAt).toLocaleDateString(languageTag())}
{m.updatedAt()}: {localeDateString(updatedAt)}
</p>
</div>
</div>