Skip to content

Commit

Permalink
Japanese holidays in 2021 for COVID-19 rescheduled Olympic games
Browse files Browse the repository at this point in the history
  • Loading branch information
tanakahisateru committed Dec 16, 2020
1 parent f37ee2e commit d4c2688
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/Yasumi/Provider/Japan.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,11 @@ private function calculateGreeneryDay(): void
private function calculateMarineDay(): void
{
$date = null;
if (2020 === $this->year) {
if (2021 === $this->year) {
// For Olympic 2021 Tokyo (after COVID-19)
$date = new DateTime("$this->year-7-22", DateTimeZoneFactory::getDateTimeZone($this->timezone));
} elseif (2020 === $this->year) {
// For Olympic 2020 Tokyo
$date = new DateTime("$this->year-7-23", DateTimeZoneFactory::getDateTimeZone($this->timezone));
} elseif ($this->year >= 2003) {
$date = new DateTime("third monday of july $this->year", DateTimeZoneFactory::getDateTimeZone($this->timezone));
Expand Down Expand Up @@ -398,7 +402,11 @@ private function calculateMarineDay(): void
private function calculateMountainDay(): void
{
$date = null;
if (2020 === $this->year) {
if (2021 === $this->year) {
// For Olympic 2021 Tokyo (after COVID-19)
$date = new DateTime("$this->year-8-8", DateTimeZoneFactory::getDateTimeZone($this->timezone));
} elseif (2020 === $this->year) {
// For Olympic 2020 Tokyo
$date = new DateTime("$this->year-8-10", DateTimeZoneFactory::getDateTimeZone($this->timezone));
} elseif ($this->year >= 2016) {
$date = new DateTime("$this->year-8-11", DateTimeZoneFactory::getDateTimeZone($this->timezone));
Expand Down Expand Up @@ -461,7 +469,11 @@ private function calculateRespectForTheAgeDay(): void
private function calculateSportsDay(): void
{
$date = null;
if (2020 === $this->year) {
if (2021 === $this->year) {
// For Olympic 2021 Tokyo (after COVID-19)
$date = new DateTime("$this->year-7-23", DateTimeZoneFactory::getDateTimeZone($this->timezone));
} elseif (2020 === $this->year) {
// For Olympic 2020 Tokyo
$date = new DateTime("$this->year-7-24", DateTimeZoneFactory::getDateTimeZone($this->timezone));
} elseif ($this->year >= 2000) {
$date = new DateTime("second monday of october $this->year", DateTimeZoneFactory::getDateTimeZone($this->timezone));
Expand Down
16 changes: 16 additions & 0 deletions tests/Japan/MarineDayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ class MarineDayTest extends JapanBaseTestCase implements YasumiTestCaseInterface
*/
public const ESTABLISHMENT_YEAR = 1996;

/**
* Tests Marine Day in 2021. Marine Day in 2021 is July 22th for rescheduled Olympic Games after COVID-19.
* @throws Exception
* @throws ReflectionException
*/
public function testMarineDayIn2021(): void
{
$year = 2021;
$this->assertHoliday(
self::REGION,
self::HOLIDAY,
$year,
new DateTime("$year-7-22", new DateTimeZone(self::TIMEZONE))
);
}

/**
* Tests Marine Day in 2020. Marine Day in 2020 is July 23th for the Olympic Games.
* @throws Exception
Expand Down
16 changes: 16 additions & 0 deletions tests/Japan/MountainDayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ class MountainDayTest extends JapanBaseTestCase implements YasumiTestCaseInterfa
*/
public const ESTABLISHMENT_YEAR = 2016;

/**
* Tests Mountain Day in 2021. Mountain Day in 2021 is August 8th for rescheduled Olympic Games after COVID-19.
* @throws Exception
* @throws ReflectionException
*/
public function testMountainDayIn2021(): void
{
$year = 2021;
$this->assertHoliday(
self::REGION,
self::HOLIDAY,
$year,
new DateTime("$year-8-8", new DateTimeZone(self::TIMEZONE))
);
}

/**
* Tests Mountain Day in 2020. Mountain Day in 2020 is August 10th for the Olympic Games.
* @throws Exception
Expand Down
17 changes: 17 additions & 0 deletions tests/Japan/SportsDayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@ class SportsDayTest extends JapanBaseTestCase implements YasumiTestCaseInterface
*/
public const ESTABLISHMENT_YEAR = 1996;

/**
* Tests Health And Sports Day in 2021. Health And Sports Day in 2021 is July 23th for rescheduled Olympic Games
* after COVID-19.
* @throws Exception
* @throws ReflectionException
*/
public function testSportsDayIn2021(): void
{
$year = 2021;
$this->assertHoliday(
self::REGION,
self::HOLIDAY,
$year,
new DateTime("$year-7-23", new DateTimeZone(self::TIMEZONE))
);
}

/**
* Tests Health And Sports Day in 2020. Health And Sports Day in 2020 is July 24th for the Olympic Games.
* @throws Exception
Expand Down

0 comments on commit d4c2688

Please sign in to comment.