Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/task/import/validate/csvEventDateValidator.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,13 @@ protected function checkDate(?string $eventDate)
return true;
}

// Check for YYYY-MM format for dates
if (preg_match('/^[0-9]{4}-(0[1-9]|1[0-2])(\s*)$/', $date)) {
// Check for YYYY-00-00/YYYY-00 format for dates
if (preg_match('/^[0-9]{4}-00(-00)?(\s*)$/', $date)) {
return true;
}

// Check for YYYY-MM/YYYY-MM-00 format for dates
if (preg_match('/^[0-9]{4}-(0[1-9]|1[0-2])(-00)?(\s*)$/', $date)) {
return true;
}

Expand Down
3 changes: 3 additions & 0 deletions test/phpunit/csvImportValidator/CsvEventDateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public function setUp(): void
'"","","","another title","","","1995","Creation","19950101","","","en"',
'"","","","yet another title","","","1997|1998","Creation|Accumulation","1997-01-01 | 1998-01-01","","","en"',
'"","","","fifth title","","","1997","Creation","19970204 ","","","en"',
'"","","","YYYY-00-00 Date format","","","2000 - 2001","Creation","2000-00-00","2001-00-00","","en"',
'"","","","YYYY-00 Date format","","","1979","Creation","1979-00","1979-00","","en"',
'"","","","YYYY-MM-00 Date format","","","June-July 1993","Creation","1993-06-00","1993-07-00","","en"',
];

// Test for invalid values in one or both fields
Expand Down
Loading