diff --git a/lib/SLUB/LZA/TA/Command/search.pm b/lib/SLUB/LZA/TA/Command/search.pm index a7ea61bcb613946f3a743dfdb558d961b16427a9..1c34e29e33f98be9443fbf98657ef4e7d6211bb5 100644 --- a/lib/SLUB/LZA/TA/Command/search.pm +++ b/lib/SLUB/LZA/TA/Command/search.pm @@ -55,11 +55,14 @@ sub opt_spec { [ 'aip|a=s' => 'search a specific AIP by given AIP id' ], [ 'datemode' => hidden => { one_of => [ - [ 'creationdate|c=s' => 'search based on creation date in format "YYYY-MM-DD", ranges in format "YYYY-MM-DD...YYYY-MM-DD"' ], + [ 'creationdate|c=s' => 'search based on creation date in format "YYYY-MM-DD"' ], + [ 'creationdate-from=s' => 'search based on creation date ranges, beginning date in format "YYYY-MM-DD", implies "--creationdate-to"'], #[ 'modificationdate|m=s' => 'search based on modificationdate string' ] ] } ], + [ 'creationdate-to=s' => 'search based on creation date ranges, beginning date in format "YYYY-MM-DD", implies "--creationdate-from"', + {implies => 'creationdate_from' }], [ 'descriptive|d=s', 'search descriptive metadata, using exact match' ], [ 'fuzzy|f=s', 'search descriptive metadata, using phrase prefix match' ], [ 'lzaid|l=s', 'search a specific AIP by given LZA id' ], @@ -132,7 +135,25 @@ sub validate_args { $opt->{creationdate_epochs}->{from} = $from_epoch; $opt->{creationdate_epochs}->{to} = $to_epoch; } else { - $self->usage_error('--creationdate expects date in format "YYYY-MM-DD", ranges in format "YYYY-MM-DD...YYYY-MM-DD"'); + $self->usage_error('--creationdate expects date in format "YYYY-MM-DD"'); + } + } + if (exists $opt->{creationdate_from}) { + $self->usage_error('--creationdate-from implies --creationdate-to"') unless exists $opt->{creationdate_to}; + if ($opt->{creationdate_from} =~ m/^(\d{4})-(\d{2})-(\d{2})$/ ) { + my $from_epoch = Date_to_Time($1, $2, $3, 0, 0, 0); + $opt->{creationdate_epochs}->{from} = $from_epoch; + } else { + $self->usage_error('--creationdate-from expects date in format "YYYY-MM-DD"'); + } + } + if (exists $opt->{creationdate_to}) { + $self->usage_error('--creationdate-to implies --creationdate-from"') unless exists $opt->{creationdate_from}; + if ($opt->{creationdate_from} =~ m/^(\d{4})-(\d{2})-(\d{2})$/ ) { + my $to_epoch = Date_to_Time($1, $2, $3, 23, 59, 59); + $opt->{creationdate_epochs}->{to} = $to_epoch; + } else { + $self->usage_error('--creationdate-to expects date in format "YYYY-MM-DD"'); } } if (exists $opt->{pronom_id}) {