Skip to content
Snippets Groups Projects
Commit da6f3167 authored by Andreas Romeyke's avatar Andreas Romeyke
Browse files

- splitted --creationdate to --creationdate-from and --creationdate-to

parent 4e58bff2
Branches
No related tags found
No related merge requests found
...@@ -55,11 +55,14 @@ sub opt_spec { ...@@ -55,11 +55,14 @@ sub opt_spec {
[ 'aip|a=s' => 'search a specific AIP by given AIP id' ], [ 'aip|a=s' => 'search a specific AIP by given AIP id' ],
[ 'datemode' => hidden => { [ 'datemode' => hidden => {
one_of => [ 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' ] #[ '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' ], [ 'descriptive|d=s', 'search descriptive metadata, using exact match' ],
[ 'fuzzy|f=s', 'search descriptive metadata, using phrase prefix match' ], [ 'fuzzy|f=s', 'search descriptive metadata, using phrase prefix match' ],
[ 'lzaid|l=s', 'search a specific AIP by given LZA id' ], [ 'lzaid|l=s', 'search a specific AIP by given LZA id' ],
...@@ -132,7 +135,25 @@ sub validate_args { ...@@ -132,7 +135,25 @@ sub validate_args {
$opt->{creationdate_epochs}->{from} = $from_epoch; $opt->{creationdate_epochs}->{from} = $from_epoch;
$opt->{creationdate_epochs}->{to} = $to_epoch; $opt->{creationdate_epochs}->{to} = $to_epoch;
} else { } 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}) { if (exists $opt->{pronom_id}) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment