Skip to content

Commit

Permalink
Report invalid date properly as part of issue #5.
Browse files Browse the repository at this point in the history
  • Loading branch information
donkirkby committed Sep 15, 2014
1 parent 14e0039 commit 77a2704
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions modules/ExtractConanDateFromSamplesheet.pm
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ sub getSampleSheetDate {

# Try to parse this date and check if it looks like it worked
my $parsed_date = str2time($samplesheet_date);
my $year = time2str("%Y", $parsed_date);
if (($year < 2010) || ($year > 2020)) { next; }
my $year = defined $parsed_date ? time2str("%Y", $parsed_date) : undef;
if ( ! defined $year || ($year < 2010) || ($year > 2020)) {
die "Invalid date in sample sheet's project name: '$samplesheet_date'.";
}
return time2str("%Y-%m-%d", $parsed_date);
}

Expand Down

0 comments on commit 77a2704

Please sign in to comment.