diff --git a/src/components/util/Date.astro b/src/components/util/Date.astro
index e207be9..9e8592d 100644
--- a/src/components/util/Date.astro
+++ b/src/components/util/Date.astro
@@ -1,10 +1,8 @@
---
-import { formattedDate, isoDate } from '~/lib/date';
export interface Props {
- date: Date;
+ date: string | Date;
showTime?: boolean;
}
-
const { date, showTime = false } = Astro.props;
if (!date) {
@@ -12,6 +10,16 @@ if (!date) {
return null;
}
+const dateObj = typeof date === "string" ? new globalThis.Date(date) : date;
+const options: Intl.DateTimeFormatOptions = { year: "numeric", month: "long", day: "numeric" };
+
+if (showTime) {
+ options.hour = "2-digit";
+ options.minute = "2-digit";
+}
+
+const formattedDate = dateObj.toLocaleString("en-GB", options);
+const isoDate = dateObj.toISOString();
---
-
+
\ No newline at end of file
diff --git a/src/lib/date.ts b/src/lib/date.ts
index e75f0f8..2451380 100644
--- a/src/lib/date.ts
+++ b/src/lib/date.ts
@@ -1,7 +1,7 @@
-function checkDate(date: Date | string): Date {
- if (typeof date === Date)
-}
+// function checkDate(date: Date | string): Date {
+// if (typeof date === Date)
+// }
export function formattedDate(date: Date, showTime: boolean): string {
const options: Intl.DateTimeFormatOptions = {