fix(magic-shelf): remove timestamp from magic shelf date checks (#2097)

This commit is contained in:
Alex
2026-07-24 22:57:10 +01:00
committed by GitHub
parent bf093b9506
commit 8edf1351b0
2 changed files with 14 additions and 17 deletions
@@ -27,14 +27,18 @@ export class BookRuleEvaluatorService {
}
const rawValue = this.extractBookValue(book, rule.field);
const isDateField = rule.field === 'publishedDate' || rule.field === 'dateFinished' ||
rule.field === 'lastReadTime' || rule.field === 'addedOn';
const withoutTime = (date: Date): Date =>
new Date(date.getFullYear(), date.getMonth(), date.getDate());
const normalize = (val: unknown): unknown => {
if (val === null || val === undefined) return val;
if (val instanceof Date) return val;
if (val instanceof Date) return isDateField ? withoutTime(val) : val;
if (typeof val === 'boolean') return String(val);
if (typeof val === 'string') {
const date = parseValue(val, 'date');
if (date != null) return date;
if (date instanceof Date) return isDateField ? withoutTime(date) : date;
return val.toLowerCase();
}
return val;