Skip to content

armgit / ente

Public Imported from GitHub
0

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

Show date suggestions for Sunday and midnight searches

Yugi44006a3eb506
diff --git a/desktop/changes/search-sunday-midnight.md b/desktop/changes/search-sunday-midnight.md
new file mode 100644
index 0000000000..beed9bc95d
--- /dev/null
+++ b/desktop/changes/search-sunday-midnight.md
@@ -0,0 +1 @@
+- Fixed searches for Sunday or midnight not showing a date suggestion. - @y9ndra
diff --git a/web/packages/new/photos/services/search/worker.ts b/web/packages/new/photos/services/search/worker.ts
index 2f1aa567a3..5d32b603aa 100644
--- a/web/packages/new/photos/services/search/worker.ts
+++ b/web/packages/new/photos/services/search/worker.ts
@@ -309,15 +309,20 @@ const parseChrono = (
const weekday = component("weekday");
const hour = component("hour");
- if (!year && !month && !day && !weekday && !hour) return undefined;
+ // Sunday is weekday 0 and midnight is hour 0.
+ const hasWeekday = weekday !== undefined;
+ const hasHour = hour !== undefined;
+
+ if (!year && !month && !day && !hasWeekday && !hasHour)
+ 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) {
+ if (hasWeekday) format.weekday = "long";
+ if (hasHour) {
format.hour = "numeric";
format.dayPeriod = "short";
}
@@ -466,8 +471,8 @@ const isDateComponentsMatch = (
if (year) match = date.getFullYear() == year;
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;
+ if (match && weekday !== undefined) match = date.getDay() == weekday;
+ if (match && hour !== undefined) match = date.getHours() == hour;
return match;
};