Skip to content

Commit

Permalink
Bug fix in the SimpleParser and add test.
Browse files Browse the repository at this point in the history
  • Loading branch information
ataiemajid63 committed Oct 1, 2021
1 parent bff7efc commit 3de9677
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Parsers/SimpleParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ public function match($pattern, $text, array $sequence)
{
if(!preg_match($pattern, $text, $matches))
{
return null;
return [];
}

$components = [];
$components = [];

for($i = 1; $i < count($matches); $i++) {
$components[$sequence[$i - 1]] = $matches[$i];
Expand Down
10 changes: 10 additions & 0 deletions tests/PasoonateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,14 @@ public function testParser()

$this->assertEquals($date, '1399/10/12 20:12:00', 'Jalali Date is ok');
}

public function testGaregorianParser()
{
$pasoonate = Pasoonate::make();
$pasoonate->gregorian()->parse('yyyy-MM-dd HH:mm:dd', '2021-10-01 13:21:25');

$date = $pasoonate->jalali()->format('dddd, dd MMMM yyyy - H:m');

$this->assertEquals($date, 'دوشنبه, 03 آبان 1400 - 13:21', 'Garegorian Date is ok');
}
}

0 comments on commit 3de9677

Please sign in to comment.