Skip to content
Merged
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
13 changes: 12 additions & 1 deletion php/libraries/Candidate.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,25 @@ class Candidate implements \LORIS\StudyEntities\AccessibleResource,
DOB_NOT_SPECIFIED
);
}
$dob = DateTime::createFromFormat('!Y-m-d', $dateOfBirth);

// Get expected format from config
$dobFormat = $config->getSetting('dobFormat');
$dobFormat = '!' . implode("-", str_split($dobFormat, 1));
$dob = DateTime::createFromFormat($dobFormat, $dateOfBirth);

if ($dob === false) {
throw new InvalidArgumentException(
"Date of Birth is invalid (expected format: YYYY-MM-DD)",
DOB_INVALID
);
}

// Add day as first of the month if Y-m dob format
// This allows insert into sql candidate table
if ($dobFormat === '!Y-m') {
$dateOfBirth .= '-15';
}

if ($PSCIDSettings['generation'] == 'user') {
// check pscid is specified
if (empty($PSCID)) {
Expand Down