From 051d029c30f3a2d404841571af3c0138afad4d02 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Tue, 2 Jan 2024 21:54:58 +0100 Subject: [PATCH] add lower and strict year to search --- utils/finder.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/utils/finder.ts b/utils/finder.ts index 389bd98..2665b7c 100644 --- a/utils/finder.ts +++ b/utils/finder.ts @@ -266,7 +266,10 @@ export default class finder { this.mini_arguments = minimist(process.argv.slice(2)) log.debug('arguments', this.mini_arguments) if (this.mini_arguments['lowerYear']) { - log.info('année minimale à retenir pour la sélection des dates:' , this.mini_arguments['lowerYear']) + log.info('année minimale à retenir pour la sélection des dates:', this.mini_arguments['lowerYear']) + } + if (this.mini_arguments['strictYear']) { + log.info('année à retenir pour la sélection des dates:', this.mini_arguments['lowerYear']) } if (!this.mini_arguments._.length) { log.info('pas de fichier ou de dossier demandé, veuillez spécifier un chemin en argument') @@ -511,7 +514,7 @@ export default class finder { return result } - static dateIsGood(date: Date):boolean { + static dateIsGood(date: Date): boolean { if (!date) { return false } @@ -520,17 +523,17 @@ export default class finder { console.log('(year > 1970)', (year > 1970)) - - let lowerYearPossible = this.mini_arguments['lowerYear'] - if(!lowerYearPossible){ + let strictYearToFind = 1 * this.mini_arguments['strictYear'] + let lowerYearPossible = 1 * this.mini_arguments['lowerYear'] + if (!lowerYearPossible) { lowerYearPossible = 2004 } let today: Date = new Date(); let higherYearPossible = today.getFullYear() - let isDateGood = (year >= lowerYearPossible) && (year <= higherYearPossible) + let isDateGood = (year === strictYearToFind) || ((year >= lowerYearPossible) && (year <= higherYearPossible)) console.log('lowerYearPossible', lowerYearPossible) - if(!isDateGood){ - log.warn(' date is not good :', date) + if (!isDateGood) { + log.warn(' date is not good :', date) } return isDateGood } @@ -549,6 +552,8 @@ export default class finder { static findEarliestDateInExifData(exifData: any) { log.debug(' finder - findEarliestDateInExifData') + this.moments = [] + if (exifData) { let exifDates: string[] = ['DateTimeOriginal', 'FileModificationDateTime', 'FileModificationDate', 'ModificationDateTime', 'ModifyDate', 'FileAccessDateTime', 'DateTime', 'FileInodeChangeDateTime', 'CreateDate']