summaryrefslogtreecommitdiff
path: root/src/components/FormattedDate.astro
blob: 45de27359ab2c376f1da9511a28e1c7b5adb148e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
---
import type { HTMLAttributes } from "astro/types";
import { getFormattedDate } from "@/utils/date";

type Props = HTMLAttributes<"time"> & {
	date: Date;
	dateTimeOptions?: Intl.DateTimeFormatOptions;
};

const { date, dateTimeOptions, ...attrs } = Astro.props;

const postDate = getFormattedDate(date, dateTimeOptions);
const ISO = date.toISOString();
---

<time datetime={ISO} title={ISO} {...attrs}>{postDate}</time>