summaryrefslogtreecommitdiff
path: root/website/src/components/FormattedDate.astro
diff options
context:
space:
mode:
Diffstat (limited to 'website/src/components/FormattedDate.astro')
-rw-r--r--website/src/components/FormattedDate.astro21
1 files changed, 21 insertions, 0 deletions
diff --git a/website/src/components/FormattedDate.astro b/website/src/components/FormattedDate.astro
new file mode 100644
index 0000000..bb7a2c0
--- /dev/null
+++ b/website/src/components/FormattedDate.astro
@@ -0,0 +1,21 @@
+---
+interface Props {
+ className?: string;
+ date: Date | string;
+}
+
+let { className, date } = Astro.props;
+if (typeof(date) === 'string') {
+ date = new Date(date);
+}
+---
+
+<time datetime={date.toISOString()} class={className ?? ''}>
+ {
+ date.toLocaleDateString('en-GB', {
+ year: 'numeric',
+ month: 'long',
+ day: 'numeric',
+ })
+ }
+</time>