diff --git a/apps/webapp/app/components/primitives/DateTime.tsx b/apps/webapp/app/components/primitives/DateTime.tsx
index 7d75bc7351..9ce1b7957c 100644
--- a/apps/webapp/app/components/primitives/DateTime.tsx
+++ b/apps/webapp/app/components/primitives/DateTime.tsx
@@ -35,30 +35,12 @@ export const DateTime = ({
}, []);
const tooltipContent = (
-
-
- {timeZone && timeZone !== "UTC" && (
- }
- />
- )}
- }
- />
- }
- />
-
-
+
);
const formattedDateTime = (
@@ -215,8 +197,10 @@ export const DateTimeAccurate = ({
date,
timeZone = "UTC",
previousDate = null,
+ showTooltip = true,
}: DateTimeProps) => {
const locales = useLocales();
+ const [localTimeZone, setLocalTimeZone] = useState("UTC");
const realDate = typeof date === "string" ? new Date(date) : date;
const realPrevDate = previousDate
? typeof previousDate === "string"
@@ -224,33 +208,37 @@ export const DateTimeAccurate = ({
: previousDate
: null;
- // Use the new Smart formatting if previousDate is provided
- const initialFormattedDateTime = realPrevDate
- ? isSameDay(realDate, realPrevDate)
- ? formatTimeOnly(realDate, timeZone, locales)
- : formatDateTimeAccurate(realDate, timeZone, locales)
- : formatDateTimeAccurate(realDate, timeZone, locales);
-
- const [formattedDateTime, setFormattedDateTime] = useState(initialFormattedDateTime);
-
useEffect(() => {
const resolvedOptions = Intl.DateTimeFormat().resolvedOptions();
- const userTimeZone = resolvedOptions.timeZone;
+ setLocalTimeZone(resolvedOptions.timeZone);
+ }, []);
- if (realPrevDate) {
- // Smart formatting based on whether date changed
- setFormattedDateTime(
- isSameDay(realDate, realPrevDate)
- ? formatTimeOnly(realDate, userTimeZone, locales)
- : formatDateTimeAccurate(realDate, userTimeZone, locales)
- );
- } else {
- // Default behavior when no previous date
- setFormattedDateTime(formatDateTimeAccurate(realDate, userTimeZone, locales));
- }
- }, [locales, realDate, realPrevDate]);
+ // Smart formatting based on whether date changed
+ const formattedDateTime = realPrevDate
+ ? isSameDay(realDate, realPrevDate)
+ ? formatTimeOnly(realDate, localTimeZone, locales)
+ : formatDateTimeAccurate(realDate, localTimeZone, locales)
+ : formatDateTimeAccurate(realDate, localTimeZone, locales);
- return {formattedDateTime.replace(/\s/g, String.fromCharCode(32))};
+ if (!showTooltip)
+ return {formattedDateTime.replace(/\s/g, String.fromCharCode(32))};
+
+ const tooltipContent = (
+
+ );
+
+ return (
+ {formattedDateTime.replace(/\s/g, String.fromCharCode(32))}}
+ content={tooltipContent}
+ side="right"
+ />
+ );
};
function formatDateTimeAccurate(date: Date, timeZone: string, locales: string[]): string {
@@ -333,3 +321,42 @@ function DateTimeTooltipContent({
);
}
+
+function TooltipContent({
+ realDate,
+ timeZone,
+ localTimeZone,
+ locales,
+}: {
+ realDate: Date;
+ timeZone?: string;
+ localTimeZone: string;
+ locales: string[];
+}) {
+ return (
+
+
+ {timeZone && timeZone !== "UTC" && (
+ }
+ />
+ )}
+ }
+ />
+ }
+ />
+
+
+ );
+}