From 2342be2bbea8084c0e57fc825c0ada65f8802fab Mon Sep 17 00:00:00 2001 From: gras Date: Wed, 3 Apr 2024 21:16:48 +0200 Subject: [PATCH] This reverts commit 893df7db74bb6f671dd9774d8bc009526f7ca7fa. --- test/backend/unit/model/sql/SearchManager.spec.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/test/backend/unit/model/sql/SearchManager.spec.ts b/test/backend/unit/model/sql/SearchManager.spec.ts index 33ec8e60..44f42ff3 100644 --- a/test/backend/unit/model/sql/SearchManager.spec.ts +++ b/test/backend/unit/model/sql/SearchManager.spec.ts @@ -132,9 +132,18 @@ describe('SearchManager', (sqlHelper: DBTestHelper) => { delete pFaceLessTmp.metadata.faces; d = new Date(); //we create a date 1 month and 1 day before now - d = Utils.addMonthToDate(d, -1); //subtract 1 month in the "human way" - d.setDate(d.getDate()-1); //subtract 1 day - pFaceLessTmp.metadata.creationDate = d.getTime(); + if ([1, 3, 5, 7, 8, 10, 0].includes(d.getMonth())) { + //Now is a month after a long month: feb (1), april (3), june (5), august(7), september(8), november (10), january (0) + pFaceLessTmp.metadata.creationDate = d.getTime() - 60 * 60 * 24 * 32 * 1000; + } else if (d.getMonth() == 2 && Utils.isDateFromLeapYear(d)) { + //march on leap years + pFaceLessTmp.metadata.creationDate = d.getTime() - 60 * 60 * 24 * 30 * 1000; + } else if (d.getMonth() == 2) { + //march (and not leap years) + pFaceLessTmp.metadata.creationDate = d.getTime() - 60 * 60 * 24 * 29 * 1000; + } else { //all other months must come after a short month with 30 days, so we subtract 31 + pFaceLessTmp.metadata.creationDate = d.getTime() - 60 * 60 * 24 * 31 * 1000; + } pFaceLessTmp.metadata.creationDateOffset = "+02:00"; dir = await DBTestHelper.persistTestDir(directory);