Skip to content

Commit 65ddc0f

Browse files
committed
feat: add DateTime component
1 parent f3b2020 commit 65ddc0f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/components/DateTime.astro

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
interface Props {
3+
value: Date;
4+
title?: string;
5+
lang?: Intl.LocalesArgument,
6+
dateStyle?: "full" | "long" | "medium" | "short"
7+
}
8+
const { value, title, lang = 'en-US', dateStyle = 'full' } = Astro.props
9+
---
10+
<time title={title} datetime={value.toISOString()}>
11+
{value.toLocaleDateString(lang, { dateStyle, timeZone: 'UTC' })}
12+
</time>

0 commit comments

Comments
 (0)