mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08:00
reverted search manager tests
This commit is contained in:
parent
893df7db74
commit
fcc123bb1b
@ -779,7 +779,7 @@ export class SearchManager {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case DatePatternFrequency.months_ago:
|
case DatePatternFrequency.months_ago:
|
||||||
to.setTime(Utils.addMonthToDate(to, -1 * tq.agoNumber).getTime());
|
to.setUTCMonth(to.getUTCMonth() - tq.agoNumber);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DatePatternFrequency.years_ago:
|
case DatePatternFrequency.years_ago:
|
||||||
|
@ -220,19 +220,6 @@ export class Utils {
|
|||||||
return dayOfYear;
|
return dayOfYear;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Adding months to a date differently from standard JS
|
|
||||||
//this function makes sure that if date is the 31st and you add a month, you will get the last day of the next month
|
|
||||||
//so adding or subtracting a month from 31st of march will give 30th of april or 28th of february respectively (29th on leap years).
|
|
||||||
static addMonthToDate(date: Date, numMonths: number) {
|
|
||||||
const result = new Date(date)
|
|
||||||
const expectedMonth = ((date.getMonth() + numMonths) % 12 + 12) % 12; //inner %12 + 12 makes correct handling of negative months
|
|
||||||
result.setMonth(result.getMonth() + numMonths);
|
|
||||||
if (result.getMonth() !== expectedMonth) {
|
|
||||||
result.setDate(0);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static renderDataSize(size: number): string {
|
static renderDataSize(size: number): string {
|
||||||
const postFixes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
const postFixes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||||||
let index = 0;
|
let index = 0;
|
||||||
|
@ -132,9 +132,18 @@ describe('SearchManager', (sqlHelper: DBTestHelper) => {
|
|||||||
delete pFaceLessTmp.metadata.faces;
|
delete pFaceLessTmp.metadata.faces;
|
||||||
d = new Date();
|
d = new Date();
|
||||||
//we create a date 1 month and 1 day before now
|
//we create a date 1 month and 1 day before now
|
||||||
d = Utils.addMonthToDate(d, -1); //subtract 1 month in the "human way"
|
if ([1, 3, 5, 7, 8, 10, 0].includes(d.getMonth())) {
|
||||||
d.setDate(d.getDate()-1); //subtract 1 day
|
//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();
|
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";
|
pFaceLessTmp.metadata.creationDateOffset = "+02:00";
|
||||||
|
|
||||||
dir = await DBTestHelper.persistTestDir(directory);
|
dir = await DBTestHelper.persistTestDir(directory);
|
||||||
|
BIN
test/tmp/sqlite.db-journal
Normal file
BIN
test/tmp/sqlite.db-journal
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user