From 690148e8a5d819630dc40efccb6b8876157806bc Mon Sep 17 00:00:00 2001 From: CamilleBeau Date: Wed, 19 Apr 2023 11:43:38 -0400 Subject: [PATCH 1/3] [candidate] Allow dob format Y-m --- php/libraries/Candidate.class.inc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/php/libraries/Candidate.class.inc b/php/libraries/Candidate.class.inc index 87f81c0ba56..7aa09643970 100644 --- a/php/libraries/Candidate.class.inc +++ b/php/libraries/Candidate.class.inc @@ -280,7 +280,12 @@ 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)", @@ -288,6 +293,12 @@ class Candidate implements \LORIS\StudyEntities\AccessibleResource, ); } + // Add day as first of the month if Y-m dob format + // This allows insert into sql candidate table + if ($dobFormat === '!Y-m') { + $dateOfBirth .= '-01'; + } + if ($PSCIDSettings['generation'] == 'user') { // check pscid is specified if (empty($PSCID)) { From eff10e30a77965bd2e2edc6252921ae4debeaf7e Mon Sep 17 00:00:00 2001 From: CamilleBeau Date: Wed, 19 Apr 2023 12:47:01 -0400 Subject: [PATCH 2/3] phpcs --- php/libraries/Candidate.class.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/libraries/Candidate.class.inc b/php/libraries/Candidate.class.inc index 7aa09643970..8dc4a5e070e 100644 --- a/php/libraries/Candidate.class.inc +++ b/php/libraries/Candidate.class.inc @@ -284,7 +284,7 @@ class Candidate implements \LORIS\StudyEntities\AccessibleResource, // Get expected format from config $dobFormat = $config->getSetting('dobFormat'); $dobFormat = '!' . implode("-", str_split($dobFormat, 1)); - $dob = DateTime::createFromFormat($dobFormat, $dateOfBirth); + $dob = DateTime::createFromFormat($dobFormat, $dateOfBirth); if ($dob === false) { throw new InvalidArgumentException( From 809b47f4a82329627c2e4f95410aa780de5bee07 Mon Sep 17 00:00:00 2001 From: CamilleBeau <51176779+CamilleBeau@users.noreply.github.com> Date: Thu, 11 May 2023 10:21:47 -0400 Subject: [PATCH 3/3] Change to 15th --- php/libraries/Candidate.class.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/libraries/Candidate.class.inc b/php/libraries/Candidate.class.inc index 8dc4a5e070e..4e4eff48f71 100644 --- a/php/libraries/Candidate.class.inc +++ b/php/libraries/Candidate.class.inc @@ -296,7 +296,7 @@ class Candidate implements \LORIS\StudyEntities\AccessibleResource, // Add day as first of the month if Y-m dob format // This allows insert into sql candidate table if ($dobFormat === '!Y-m') { - $dateOfBirth .= '-01'; + $dateOfBirth .= '-15'; } if ($PSCIDSettings['generation'] == 'user') {