Skip to content

Commit

Permalink
Merge pull request #107 from seth-shaw-asu/four-digit-years
Browse files Browse the repository at this point in the history
Revert accepting 3-digit years
  • Loading branch information
rosiel authored Aug 23, 2023
2 parents e7779e4 + d5033c2 commit 6a3c63a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/EDTFUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ public static function validateDate($datetime_str, $strict = FALSE) {
elseif (strlen(ltrim($parsed_date[self::YEAR_BASE], '-')) > 4) {
$msgs[] = "Years longer than 4 digits must be prefixed with a 'Y'.";
}
elseif (strlen($parsed_date[self::YEAR_BASE]) < 4) {
$msgs[] = "Years must be at least 4 characters long.";
}
$strict_pattern = 'Y';

// Month.
Expand Down
5 changes: 3 additions & 2 deletions tests/src/Kernel/EdtfUtilsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ class EdtfUtilsTest extends KernelTestBase {
'19000' => ['Years longer than 4 digits must be prefixed with a \'Y\'.'],
'Y19000' => [],
'190u' => ['Could not parse the date \'190u\'.'],
'190' => [],
'190' => ['Years must be at least 4 characters long.'],
'190-99-52' => [
'Years must be at least 4 characters long.',
'Provided month value \'99\' is not valid.',
'Provided day value \'52\' is not valid.',
],
Expand Down Expand Up @@ -79,7 +80,7 @@ public function testIso8601() {
'19000' => '',
'Y19000' => '19000',
'190u' => '',
'190' => '190',
'190' => '',
'190-99-52' => '',
'1900-01-02T' => '',
'1900-01-02T1:1:1' => '',
Expand Down

0 comments on commit 6a3c63a

Please sign in to comment.