add lower and strict year to search

This commit is contained in:
Tykayn 2024-01-02 21:54:58 +01:00 committed by tykayn
parent 9a65f2fb7e
commit 051d029c30
1 changed files with 13 additions and 8 deletions

View File

@ -266,7 +266,10 @@ export default class finder {
this.mini_arguments = minimist(process.argv.slice(2)) this.mini_arguments = minimist(process.argv.slice(2))
log.debug('arguments', this.mini_arguments) log.debug('arguments', this.mini_arguments)
if (this.mini_arguments['lowerYear']) { 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) { if (!this.mini_arguments._.length) {
log.info('pas de fichier ou de dossier demandé, veuillez spécifier un chemin en argument') 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 return result
} }
static dateIsGood(date: Date):boolean { static dateIsGood(date: Date): boolean {
if (!date) { if (!date) {
return false return false
} }
@ -520,17 +523,17 @@ export default class finder {
console.log('(year > 1970)', (year > 1970)) console.log('(year > 1970)', (year > 1970))
let strictYearToFind = 1 * this.mini_arguments['strictYear']
let lowerYearPossible = this.mini_arguments['lowerYear'] let lowerYearPossible = 1 * this.mini_arguments['lowerYear']
if(!lowerYearPossible){ if (!lowerYearPossible) {
lowerYearPossible = 2004 lowerYearPossible = 2004
} }
let today: Date = new Date(); let today: Date = new Date();
let higherYearPossible = today.getFullYear() let higherYearPossible = today.getFullYear()
let isDateGood = (year >= lowerYearPossible) && (year <= higherYearPossible) let isDateGood = (year === strictYearToFind) || ((year >= lowerYearPossible) && (year <= higherYearPossible))
console.log('lowerYearPossible', lowerYearPossible) console.log('lowerYearPossible', lowerYearPossible)
if(!isDateGood){ if (!isDateGood) {
log.warn(' date is not good :', date) log.warn(' date is not good :', date)
} }
return isDateGood return isDateGood
} }
@ -549,6 +552,8 @@ export default class finder {
static findEarliestDateInExifData(exifData: any) { static findEarliestDateInExifData(exifData: any) {
log.debug(' finder - findEarliestDateInExifData') log.debug(' finder - findEarliestDateInExifData')
this.moments = []
if (exifData) { if (exifData) {
let exifDates: string[] = ['DateTimeOriginal', 'FileModificationDateTime', 'FileModificationDate', 'ModificationDateTime', 'ModifyDate', 'FileAccessDateTime', 'DateTime', 'FileInodeChangeDateTime', 'CreateDate'] let exifDates: string[] = ['DateTimeOriginal', 'FileModificationDateTime', 'FileModificationDate', 'ModificationDateTime', 'ModifyDate', 'FileAccessDateTime', 'DateTime', 'FileInodeChangeDateTime', 'CreateDate']