aboutsummaryrefslogtreecommitdiff
path: root/examples/starlog/src/components/FormattedDate.astro
diff options
context:
space:
mode:
Diffstat (limited to 'examples/starlog/src/components/FormattedDate.astro')
-rw-r--r--examples/starlog/src/components/FormattedDate.astro25
1 files changed, 25 insertions, 0 deletions
diff --git a/examples/starlog/src/components/FormattedDate.astro b/examples/starlog/src/components/FormattedDate.astro
new file mode 100644
index 000000000..377286d9f
--- /dev/null
+++ b/examples/starlog/src/components/FormattedDate.astro
@@ -0,0 +1,25 @@
+---
+import type { HTMLAttributes } from 'astro/types';
+
+type Props = HTMLAttributes<'time'> & {
+ date: Date;
+};
+
+const { date, ...attrs } = Astro.props;
+---
+
+<time datetime={date.toISOString()} {...attrs}>
+ {
+ date.toLocaleDateString('en-us', {
+ year: 'numeric',
+ month: 'short',
+ day: 'numeric',
+ })
+ }
+</time>
+
+<style>
+ time {
+ display: block;
+ }
+</style>