Skip to content

Commit

Permalink
Fix #1497 hasFormat more strict with full-year (#1499)
Browse files Browse the repository at this point in the history
* Fix #1497 hasFormat more strict with full-year
  • Loading branch information
kylekatarnls authored Nov 8, 2018
1 parent 0b73787 commit 19201b8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Carbon/Carbon.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class Carbon extends DateTime implements JsonSerializable
't' => '(2[89]|3[01])',
'L' => '(0|1)',
'o' => '([1-9][0-9]{0,4})',
'Y' => '([1-9][0-9]{0,4})',
'Y' => '([1-9]?[0-9]{4})',
'y' => '([0-9]{2})',
'a' => '(am|pm)',
'A' => '(AM|PM)',
Expand All @@ -217,8 +217,8 @@ class Carbon extends DateTime implements JsonSerializable
'U' => '([0-9]*)',

// The formats below are combinations of the above formats.
'c' => '(([1-9][0-9]{0,4})\-(1[012]|0[1-9])\-(3[01]|[12][0-9]|0[1-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])[\+\-](1[012]|0[0-9]):([0134][05]))', // Y-m-dTH:i:sP
'r' => '(([a-zA-Z]{3}), ([123][0-9]|[1-9]) ([a-zA-Z]{3}) ([1-9][0-9]{0,4}) (2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9]) [\+\-](1[012]|0[0-9])([0134][05]))', // D, j M Y H:i:s O
'c' => '(([1-9]?[0-9]{4})\-(1[012]|0[1-9])\-(3[01]|[12][0-9]|0[1-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])[\+\-](1[012]|0[0-9]):([0134][05]))', // Y-m-dTH:i:sP
'r' => '(([a-zA-Z]{3}), ([123][0-9]|[1-9]) ([a-zA-Z]{3}) ([1-9]?[0-9]{4}) (2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9]) [\+\-](1[012]|0[0-9])([0134][05]))', // D, j M Y H:i:s O
);

/**
Expand Down
1 change: 1 addition & 0 deletions tests/Carbon/IsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -804,5 +804,6 @@ public function testHasFormat()

// Regex failure
$this->assertFalse(Carbon::hasFormat('1975-5-1', 'Y-m-d'));
$this->assertFalse(Carbon::hasFormat('19-05-01', 'Y-m-d'));
}
}
1 change: 1 addition & 0 deletions tests/CarbonPeriod/AliasTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public function testModifyIntervalSingular()

public function testChainAliases()
{
Carbon::setTestNow('2018-05-15');
$period = CarbonPeriod::days(3)->hours(5)->invert()
->sinceNow()->until(Carbon::now()->subDays(10))
->options(CarbonPeriod::EXCLUDE_START_DATE)
Expand Down

0 comments on commit 19201b8

Please sign in to comment.