Skip to content

Commit

Permalink
feat: add function to get day of omer (#20)
Browse files Browse the repository at this point in the history
* add function to get day of omer

* update syntax

* fix omer tests

* fix lint complaints
  • Loading branch information
zachweix authored Jul 7, 2021
1 parent 782dae2 commit 591702a
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Moadim/Moadim.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ trait Moadim
use CholHamoed;
use RoshChodesh;
use AseresYimeiTeshuva;
use Omer;

/**
* Get if we're set to Galus or Israel.
Expand Down
26 changes: 26 additions & 0 deletions src/Moadim/Omer.php
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;
}
}
19 changes: 19 additions & 0 deletions tests/Moadim/OmerTest.php
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());
}
}

0 comments on commit 591702a

Please sign in to comment.