Skip to content

Commit

Permalink
Bug Fixed "bridge day" at Japan. (azuyalabs#141)
Browse files Browse the repository at this point in the history
"Bridge day" has 2 days in 2019 (Apr 30th & May 2nd).
  • Loading branch information
cookie-maker authored and stelgenhof committed Mar 28, 2019
1 parent 7fd0bdd commit 49eff53
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/Yasumi/Provider/Japan.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ public function initialize(): void
$this->calculateSportsDay();
$this->calculateAutumnalEquinoxDay();
$this->calculateSubstituteHolidays();
$this->calculateBridgeHolidays();
$this->calculateCoronationDay();
$this->calculateEnthronementProclamationCeremony();
$this->calculateBridgeHolidays();
}

/**
Expand Down Expand Up @@ -607,6 +607,7 @@ private function calculateBridgeHolidays(): void
// Get initial list of holidays and iterator
$datesIterator = $this->getIterator();

$counter=1;
// Loop through all defined holidays
while ($datesIterator->valid()) {
$previous = $datesIterator->current();
Expand All @@ -622,10 +623,11 @@ private function calculateBridgeHolidays(): void
$bridgeDate = clone $previous;
$bridgeDate->add(new DateInterval('P1D'));

$this->addHoliday(new Holiday('bridgeDay', [
$this->addHoliday(new Holiday('bridgeDay'.$counter, [
'en_US' => 'Bridge Public holiday',
'ja_JP' => '国民の休日',
], $bridgeDate, $this->locale));
$counter++;
}
}
}
Expand Down
16 changes: 11 additions & 5 deletions tests/Japan/PublicBridgeDayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,15 @@ public function testPublicBridgeDay()
{
$this->assertHoliday(
self::REGION,
self::HOLIDAY,
self::HOLIDAY.'1',
$this->year,
new DateTime("$this->year-9-22", new DateTimeZone(self::TIMEZONE))
new DateTime("$this->year-4-30", new DateTimeZone(self::TIMEZONE))
);
$this->assertHoliday(
self::REGION,
self::HOLIDAY.'2',
$this->year,
new DateTime("$this->year-5-2", new DateTimeZone(self::TIMEZONE))
);
}

Expand All @@ -52,7 +58,7 @@ public function testPublicBridgeDay()
*/
public function testTranslation(): void
{
$this->assertTranslatedHolidayName(self::REGION, self::HOLIDAY, $this->year, [self::LOCALE => '国民の休日']);
$this->assertTranslatedHolidayName(self::REGION, self::HOLIDAY.'1', $this->year, [self::LOCALE => '国民の休日']);
}

/**
Expand All @@ -61,14 +67,14 @@ public function testTranslation(): void
*/
public function testHolidayType(): void
{
$this->assertHolidayType(self::REGION, self::HOLIDAY, $this->year, Holiday::TYPE_OFFICIAL);
$this->assertHolidayType(self::REGION, self::HOLIDAY.'1', $this->year, Holiday::TYPE_OFFICIAL);
}

/**
* Initial setup of this Test Case
*/
protected function setUp()
{
$this->year = 2015;
$this->year = 2019;
}
}

0 comments on commit 49eff53

Please sign in to comment.