Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Use

Manav Rathi1b90fa93eea9
diff --git a/web/packages/base/i18n-date.ts b/web/packages/base/i18n-date.ts
index 56d751387c..2a8e21f95f 100644
--- a/web/packages/base/i18n-date.ts
+++ b/web/packages/base/i18n-date.ts
@@ -29,9 +29,9 @@ const _timeFormat = new Intl.DateTimeFormat(i18n.language, {
* The behaviour depends upon whether the given {@link date} falls within the
* current calendar year.
*
- * - For dates in the current year, year is omitted. Example: "Fri, 21 Feb"
+ * - For dates in the current year, year is omitted, e.g, "Fri, 21 Feb".
*
- * - Otherwise, the year is included. Example: "Fri, 21 Feb 2025"
+ * - Otherwise, the year is included, e.g., "Fri, 21 Feb 2025".
*/
export const formattedDate = (date: Date) =>
(isSameYear(date) ? _dateWithoutYearFormat : _dateFormat).format(date);
diff --git a/web/packages/gallery/components/FileInfo.tsx b/web/packages/gallery/components/FileInfo.tsx
index 045b217e17..b60e0863f1 100644
--- a/web/packages/gallery/components/FileInfo.tsx
+++ b/web/packages/gallery/components/FileInfo.tsx
@@ -21,6 +21,7 @@ import {
import { useBaseContext } from "@/base/context";
import { haveWindow } from "@/base/env";
import { nameAndExtension } from "@/base/file-name";
+import { formattedDate, formattedTime } from "@/base/i18n-date";
import log from "@/base/log";
import type { Location } from "@/base/types";
import { CopyButton } from "@/gallery/components/FileInfoComponents";
@@ -62,7 +63,6 @@ import SingleInputForm, {
type SingleInputFormProps,
} from "@ente/shared/components/SingleInputForm";
import { getPublicMagicMetadataSync } from "@ente/shared/file-metadata";
-import { formatDate, formatTime } from "@ente/shared/time/format";
import CalendarTodayIcon from "@mui/icons-material/CalendarToday";
import CameraOutlinedIcon from "@mui/icons-material/CameraOutlined";
import CloseIcon from "@mui/icons-material/Close";
@@ -480,24 +480,22 @@ const InfoItem: React.FC<React.PropsWithChildren<InfoItemProps>> = ({
sx={{ alignItems: "flex-start", flex: 1, gap: "12px" }}
>
<InfoItemIconContainer>{icon}</InfoItemIconContainer>
- <Box sx={{ flex: 1, mt: "4px" }}>
- {children ?? (
- <>
- <Typography sx={{ wordBreak: "break-all" }}>
- {title}
- </Typography>
- <Typography
- variant="small"
- {...(typeof caption == "string"
- ? {}
- : { component: "div" })}
- sx={{ color: "text.muted" }}
- >
- {caption}
- </Typography>
- </>
- )}
- </Box>
+ {children ? (
+ <Box sx={{ flex: 1, mt: "4px" }}>{children}</Box>
+ ) : (
+ <Stack sx={{ flex: 1, mt: "4px", gap: "4px" }}>
+ <Typography sx={{ wordBreak: "break-all" }}>{title}</Typography>
+ <Typography
+ variant="small"
+ {...(typeof caption == "string"
+ ? {}
+ : { component: "div" })}
+ sx={{ color: "text.muted" }}
+ >
+ {caption}
+ </Typography>
+ </Stack>
+ )}
{trailingButton}
</Stack>
);
@@ -717,8 +715,8 @@ const CreationTime: React.FC<CreationTimeProps> = ({
<FlexWrapper>
<InfoItem
icon={<CalendarTodayIcon />}
- title={formatDate(originalDate)}
- caption={formatTime(originalDate)}
+ title={formattedDate(originalDate)}
+ caption={formattedTime(originalDate)}
trailingButton={
allowEdits && (
<EditButton
diff --git a/web/packages/shared/time/format.ts b/web/packages/shared/time/format.ts
index 4a728cad4d..06638a66c6 100644
--- a/web/packages/shared/time/format.ts
+++ b/web/packages/shared/time/format.ts
@@ -32,7 +32,7 @@ export function formatDate(date: number | Date) {
.join(" ");
}
-export function formatTime(date: number | Date) {
+function formatTime(date: number | Date) {
return timeFormatter.format(date).toUpperCase();
}