Skip to content

Commit

Permalink
Fix #1943 Add example for H:s.vi (#1944)
Browse files Browse the repository at this point in the history
* Fix #1943 Add example for H:s.vi

* Fix #1943 Drop support of .v for PHP < 7.3

* Fix test PHP < 7.2 compatibility
  • Loading branch information
kylekatarnls authored Nov 20, 2019
1 parent 630c8c8 commit 13b8485
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/Carbon/IsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,11 @@ public function testHasFormat()
$this->assertTrue(Carbon::hasFormat('2000-07-01T00:00:00+00:00', Carbon::ATOM));
$this->assertTrue(Carbon::hasFormat('Y-01-30\\', '\\Y-m-d\\\\'));

if (version_compare(PHP_VERSION, '7.3.0-dev', '>=')) {
// Due to https://bugs.php.net/bug.php?id=75577, proper "v" format support can only works from PHP 7.3.0.
$this->assertTrue(Carbon::hasFormat('2012-12-04 22:59.32130', 'Y-m-d H:s.vi'));
}

// Format failure
$this->assertFalse(Carbon::hasFormat('1975-05-01', 'd m Y'));
$this->assertFalse(Carbon::hasFormat('Foo 21st', 'D jS'));
Expand Down
8 changes: 8 additions & 0 deletions tests/CarbonImmutable/IsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,14 @@ public function testHasFormat()
$this->assertTrue(Carbon::hasFormat('30/12/2019', 'd/m/Y'));
$this->assertTrue(Carbon::hasFormat('Sun 21st', 'D jS'));

$this->assertTrue(Carbon::hasFormat('2000-07-01T00:00:00+00:00', DateTime::ATOM));
$this->assertTrue(Carbon::hasFormat('Y-01-30\\', '\\Y-m-d\\\\'));

if (version_compare(PHP_VERSION, '7.3.0-dev', '>=')) {
// Due to https://bugs.php.net/bug.php?id=75577, proper "v" format support can only works from PHP 7.3.0.
$this->assertTrue(Carbon::hasFormat('2012-12-04 22:59.32130', 'Y-m-d H:s.vi'));
}

// Format failure
$this->assertFalse(Carbon::hasFormat('1975-05-01', 'd m Y'));
$this->assertFalse(Carbon::hasFormat('Foo 21st', 'D jS'));
Expand Down

0 comments on commit 13b8485

Please sign in to comment.