-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add function to get day of omer (#20)
* add function to get day of omer * update syntax * fix omer tests * fix lint complaints
- Loading branch information
Showing
3 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace Zman\Moadim; | ||
|
||
trait Omer | ||
{ | ||
/** | ||
* The Omer goes from 1 to 49 from Pesach to Shavuos. | ||
* | ||
* @return bool | ||
*/ | ||
public function getOmerCount() | ||
{ | ||
if ($this->jewishMonth == 8 && $this->jewishDay >= 16) { | ||
return $this->jewishDay - 15; | ||
} | ||
if ($this->jewishMonth == 9) { | ||
return $this->jewishDay + 15; | ||
} | ||
if ($this->jewishMonth == 10 && $this->jewishDay <= 5) { | ||
return $this->jewishDay + 44; | ||
} | ||
|
||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Test\Moadim; | ||
|
||
use Zman\Zman; | ||
|
||
class OmerTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
/** @test */ | ||
public function checks_omer_count() | ||
{ | ||
$this->assertEquals(0, Zman::parse('March 28, 2021')->getOmerCount()); | ||
$this->assertEquals(1, Zman::parse('March 29, 2021')->getOmerCount()); | ||
$this->assertEquals(33, Zman::parse('April 30, 2021')->getOmerCount()); | ||
$this->assertEquals(49, Zman::parse('May 16, 2021')->getOmerCount()); | ||
$this->assertEquals(0, Zman::parse('May 17, 2021')->getOmerCount()); | ||
$this->assertEquals(0, Zman::parse('November 14, 2021')->getOmerCount()); | ||
} | ||
} |