Skip to content

Commit

Permalink
International Womens Day (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
huehnerhose authored and stelgenhof committed Feb 12, 2019
1 parent 9fbfd6f commit f756448
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 29 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Added Reformation Day as offical holiday since 2018 in Schleswig-Holstein (Germany). [#106](https://github.com/azuyalabs/yasumi/pull/106) ([HenningCash](https://github.com/HenningCash))
- Added Reformation Day as offical holiday since 2018 in Hamburg (Germany). [#108](https://github.com/azuyalabs/yasumi/pull/108) ([HenningCash](https://github.com/HenningCash))
- Added Reformation Day as offical holiday since 2018 in Bremen (Germany). [#116](https://github.com/azuyalabs/yasumi/issues/116) ([TalonTR](https://github.com/TalonTR))
- Added International Women's Day as official holidy since 2019 in Berlin (Germany). [#133](https://github.com/azuyalabs/yasumi/pull/133) ([huehnerhose](https://github.com/huehnerhose))
- The (observed) holidays Lukkeloven, Constitution Day, New Year's Eve and Labour Day, as well as summertime and wintertime are included for Denmark [\#104](https://github.com/azuyalabs/yasumi/pull/104) ([c960657](https://github.com/c960657))

### Changed
Expand All @@ -37,7 +38,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Updated copyright year.
- Upgraded various dependency packages.
- Internal locale list updated based on CLDR v34.
- Refactored the Japan and USA Holiday Provider by moving the holiday calculations to private methods. This reduced the complexity of the initialize method.
- Refactored the Japan and USA Holiday Provider by moving the holiday calculations to private methods. This reduced the complexity of the initialize method.
- Changed individual added International Women's Day for Ukraine and Russia to common holiday. [#133](https://github.com/azuyalabs/yasumi/pull/133) ([huehnerhose](https://github.com/huehnerhose))

### Fixed
- Translation for Russia showed in English (except New Year's Day) as the proper locale was not in place.
Expand Down
35 changes: 35 additions & 0 deletions src/Yasumi/Provider/CommonHolidays.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,41 @@ public function armisticeDay(
);
}

/**
* International Women's Day
*
* International Women's Day (IWD) is celebrated on March 8 every year.[3] It is a focal point in the movement for women's rights.
*
* @link https://en.wikipedia.org/wiki/International_Women%27s_Day
*
* @param int $year the year for which International Women's Day need to be created
* @param string $timezone the timezone in which International Women's Day is celebrated
* @param string $locale the locale for which International Women's Day need to be displayed in.
* @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
* TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default an official holiday is considered.
*
* @return \Yasumi\Holiday
*
* @throws \Yasumi\Exception\InvalidDateException
* @throws \Yasumi\Exception\UnknownLocaleException
* @throws \InvalidArgumentException
* @throws \Exception
*/
public function internationalWomensDay(
int $year,
string $timezone,
string $locale,
string $type = Holiday::TYPE_OFFICIAL
): Holiday {
return new Holiday(
'internationalWomensDay',
[],
new DateTime("$year-03-08", new DateTimeZone($timezone)),
$locale,
$type
);
}

/**
* Calculates daylight saving time transitions.
*
Expand Down
17 changes: 17 additions & 0 deletions src/Yasumi/Provider/Germany/Berlin.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,21 @@ class Berlin extends Germany
* country or sub-region.
*/
public const ID = 'DE-BE';

/**
* Initialize holidays for Berlin (Germany).
*
* @throws \Yasumi\Exception\InvalidDateException
* @throws \InvalidArgumentException
* @throws \Yasumi\Exception\UnknownLocaleException
* @throws \Exception
*/
public function initialize(): void
{
parent::initialize();

if ($this->year >= 2019) {
$this->addHoliday($this->internationalWomensDay($this->year, $this->timezone, $this->locale));
}
}
}
5 changes: 1 addition & 4 deletions src/Yasumi/Provider/Russia.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,7 @@ private function addDefenceOfTheFatherlandDay(): void
*/
private function addInternationalWomensDay(): void
{
$this->addHoliday(new Holiday('internationalWomensDay', [
'en_US' => 'International Women\'s Day',
'ru_RU' => 'Международный женский день'
], new \DateTime("{$this->year}-03-08", new \DateTimeZone($this->timezone)), $this->locale));
$this->addHoliday($this->internationalWomensDay($this->year, $this->timezone, $this->locale));
}

/**
Expand Down
25 changes: 1 addition & 24 deletions src/Yasumi/Provider/Ukraine.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ public function initialize(): void
// Add common holidays
$this->addHoliday($this->newYearsDay($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->internationalWorkersDay($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->internationalWomensDay($this->year, $this->timezone, $this->locale));

// Add Christian holidays
$this->addHoliday($this->easter($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->pentecost($this->year, $this->timezone, $this->locale));

// Add other holidays
$this->calculateChristmasDay();
$this->calculateInternationalWomensDay();
$this->calculateSecondInternationalWorkersDay();
$this->calculateVictoryDay();
$this->calculateConstitutionDay();
Expand All @@ -80,29 +80,6 @@ public function calculateChristmasDay(): void
));
}

/**
* International Women's Day.
*
* International Women's Day (IWD), originally called International Working Women's Day, is celebrated on March 8
* every year.
*
* @link https://en.wikipedia.org/wiki/International_Women%27s_Day
*
* @throws \Yasumi\Exception\InvalidDateException
* @throws \InvalidArgumentException
* @throws \Yasumi\Exception\UnknownLocaleException
* @throws \Exception
*/
public function calculateInternationalWomensDay(): void
{
$this->addHoliday(new Holiday(
'internationalWomensDay',
['uk_UA' => 'Міжнародний жіночий день', 'ru_UA' => 'Международный женский день'],
new \DateTime("$this->year-03-08", new \DateTimeZone($this->timezone)),
$this->locale
));
}

/**
* International Workers' Day.
*
Expand Down
20 changes: 20 additions & 0 deletions src/Yasumi/data/translations/internationalWomensDay.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
/**
* This file is part of the Yasumi package.
*
* Copyright (c) 2015 - 2019 AzuyaLabs
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Sacha Telgenhof <[email protected]>
*/

// Translations for International Women's Day
return [
'de_DE' => 'Internationaler Frauentag',
'en_US' => 'International Women\'s Day',
'ru_RU' => 'Международный женский день',
'uk_UA' => 'Міжнародний жіночий день',
'ru_UA' => 'Международный женский день',
];
99 changes: 99 additions & 0 deletions tests/Germany/Berlin/InternationalWomensDay2019Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?php
/**
* This file is part of the Yasumi package.
*
* Copyright (c) 2015 - 2019 AzuyaLabs
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Sacha Telgenhof <[email protected]>
*/

namespace Yasumi\tests\Germany\Berlin;

use DateTime;
use DateTimeZone;
use Yasumi\Holiday;
use Yasumi\tests\YasumiTestCaseInterface;

/**
* Class containing tests for Reformation Day in Germany.
*/
class InternationalWomensDay2019Test extends BerlinBaseTestCase implements YasumiTestCaseInterface
{
/**
* The name of the holiday to be tested
*/
public const HOLIDAY = 'internationalWomensDay';

/**
* The year in which the holiday was established
*/
public const ESTABLISHMENT_YEAR = 2019;

/**
* Test the holiday defined in this test upon establishment
* @throws \Exception
* @throws \ReflectionException
*/
public function testHolidayOnEstablishment()
{
$this->assertHoliday(
self::REGION,
self::HOLIDAY,
self::ESTABLISHMENT_YEAR,
new DateTime(self::ESTABLISHMENT_YEAR . '-03-08', new DateTimeZone(self::TIMEZONE))
);
}

/**
* Test the holiday defined in this test before establishment
* @throws \ReflectionException
*/
public function testHolidayBeforeEstablishment()
{
$this->assertNotHoliday(
self::REGION,
self::HOLIDAY,
$this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
);
}

/**
* Test the holiday defined in this test after completion
* @throws \ReflectionException
*/
public function testHolidayAfterCompletion()
{
$this->assertNotHoliday(self::REGION, self::HOLIDAY, $this->generateRandomYear(1900, self::ESTABLISHMENT_YEAR - 1));
}

/**
* Tests the translated name of the holiday defined in this test.
* @throws \ReflectionException
*/
public function testTranslation(): void
{
$this->assertTranslatedHolidayName(
self::REGION,
self::HOLIDAY,
$this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::ESTABLISHMENT_YEAR),
[self::LOCALE => 'Internationaler Frauentag']
);
}

/**
* Tests type of the holiday defined in this test.
* @throws \ReflectionException
*/
public function testHolidayType(): void
{
$this->assertHolidayType(
self::REGION,
self::HOLIDAY,
$this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::ESTABLISHMENT_YEAR),
Holiday::TYPE_OFFICIAL
);
}
}

0 comments on commit f756448

Please sign in to comment.