Skip to content

armgit / ente

Public Imported from GitHub
0

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

Hour

Manav Rathiee3a9202278d
diff --git a/web/apps/photos/src/worker/search.worker.ts b/web/apps/photos/src/worker/search.worker.ts
index 6308a8d3c5..660a40108d 100644
--- a/web/apps/photos/src/worker/search.worker.ts
+++ b/web/apps/photos/src/worker/search.worker.ts
@@ -68,7 +68,7 @@ function isSearchedFile(file: EnteFile, search: Search) {
}
const isDateComponentsMatch = (
- { year, month, day, weekday }: SearchDateComponents,
+ { year, month, day, weekday, hour }: SearchDateComponents,
date: Date,
) => {
// Components are guaranteed to have at least one attribute present, so
@@ -80,6 +80,7 @@ const isDateComponentsMatch = (
if (match && month) match = date.getMonth() + 1 == month;
if (match && day) match = date.getDate() == day;
if (match && weekday) match = date.getDay() == weekday;
+ if (match && hour) match = date.getHours() == hour;
return match;
};
diff --git a/web/packages/new/photos/services/search/index.ts b/web/packages/new/photos/services/search/index.ts
index 75e98e280c..586e0d08f4 100644
--- a/web/packages/new/photos/services/search/index.ts
+++ b/web/packages/new/photos/services/search/index.ts
@@ -40,15 +40,17 @@ export const parseChrono = (s: string): DateSearchResult[] =>
const month = component("month");
const day = component("day");
const weekday = component("weekday");
+ const hour = component("hour");
- if (!year && !month && !day && !weekday) return undefined;
- const components = { year, month, day, weekday };
+ if (!year && !month && !day && !weekday && !hour) return undefined;
+ const components = { year, month, day, weekday, hour };
const format: Intl.DateTimeFormatOptions = {};
if (year) format.year = "numeric";
if (month) format.month = "long";
if (day) format.day = "numeric";
if (weekday) format.weekday = "long";
+ if (hour) format.hour = "2-digit";
const formatter = new Intl.DateTimeFormat(undefined, format);
const label = formatter.format(p.date());
diff --git a/web/packages/new/photos/services/search/types.ts b/web/packages/new/photos/services/search/types.ts
index 458de6a8b9..f80a4b4565 100644
--- a/web/packages/new/photos/services/search/types.ts
+++ b/web/packages/new/photos/services/search/types.ts
@@ -30,6 +30,11 @@ export interface SearchDateComponents {
* specified one.
*/
weekday?: number;
+ /**
+ * The hour of the day (0 to 23, with 0 as midnight), if the search string
+ * specified one.
+ */
+ hour?: number;
}
/**