Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bug #18953: Wrong calculation of Advent Holidays.

  • Loading branch information...
commit d3021dc356646aae5595a427417e1f537fc49997 1 parent 5156cc1
@kenguest kenguest authored
View
2  Date/Holidays/Driver/Austria.php
@@ -304,7 +304,7 @@ function _buildHolidays()
*/
$firstAdv = new Date($this->_year . '-12-03');
$dayOfWeek = $firstAdv->getDayOfWeek();
- $firstAdv = $this->_addDays($firstAdv, -$dayOfWeek);
+ $firstAdv = $this->_addDays($firstAdv, - $dayOfWeek);
$this->_addHoliday(
'firstAdvent',
$firstAdv,
View
21 package_austria.xml
@@ -16,10 +16,10 @@
<email>luckec@php.net</email>
<active>yes</active>
</lead>
- <date>2009-08-03</date>
- <time>17:56:41</time>
+ <date>2013-02-02</date>
+ <time>00:24:41</time>
<version>
- <release>0.1.4</release>
+ <release>0.1.5</release>
<api>0.1.0</api>
</version>
<stability>
@@ -122,5 +122,20 @@
* Utilise fix for Bug #13865: One-hour-shift in Christian driver
</notes>
</release>
+ <release>
+ <version>
+ <release>0.1.4</release>
+ <api>0.1.0</api>
+ </version>
+ <stability>
+ <release>alpha</release>
+ <api>alpha</api>
+ </stability>
+ <date>2009-08-03</date>
+ <license uri="http://www.php.net/license">PHP License</license>
+ <notes>
+ * Add Official filter - thanks to Karin Seifert-Lorenz
+ </notes>
+ </release>
</changelog>
</package>
View
165 tests/Date_Holidays_Driver_Austria_TestSuite.php
@@ -29,8 +29,11 @@
class Date_Holidays_Driver_Austria_TestSuite extends PHPUnit_Framework_TestCase
{
+ var $testDates2005;
var $testDates2006;
var $testDates2007;
+ var $testDates2008;
+ var $testDates2011;
/**
* setUp
@@ -40,7 +43,12 @@ class Date_Holidays_Driver_Austria_TestSuite extends PHPUnit_Framework_TestCase
*/
function setUp()
{
-
+ $this->testDates2005 = array(
+ 'firstAdvent' => array('day' => 27, 'month' => 11, 'year' => 2005),
+ 'secondAdvent' => array('day' => 4, 'month' => 12, 'year' => 2005),
+ 'thirdAdvent' => array('day' => 11, 'month' => 12, 'year' => 2005),
+ 'fourthAdvent' => array('day' => 18, 'month' => 12, 'year' => 2005),
+ );
$this->testDates2006 = array(
'newYearsDay' => array('day' => 1,
'month' => 1,
@@ -66,7 +74,19 @@ function setUp()
'allSaintsDay' => array('day' => 1,
'month' => 11,
'year' => 2006),
- 'christmasDay' => array('day' => 25,
+ 'firstAdvent' => array('day' => 3,
+ 'month' => 12,
+ 'year' => 2006),
+ 'secondAdvent' => array('day' => 10,
+ 'month' => 12,
+ 'year' => 2006),
+ 'thirdAdvent' => array('day' => 17,
+ 'month' => 12,
+ 'year' => 2006),
+ 'fourthAdvent' => array('day' => 24,
+ 'month' => 12,
+ 'year' => 2006),
+ 'christmasDay' => array('day' => 25,
'month' => 12,
'year' => 2006),
'boxingDay' => array('day' => 26,
@@ -101,29 +121,83 @@ function setUp()
'allSaintsDay' => array('day' => 1,
'month' => 11,
'year' => 2007),
- 'christmasDay' => array('day' => 25,
+ 'christmasDay' => array('day' => 25,
'month' => 12,
'year' => 2007),
'boxingDay' => array('day' => 26,
'month' => 12,
'year' => 2007)
);
+ $this->testDates2008 = array(
+ 'fourthAdvent' => array('day' => 21, 'month' => 12, 'year' => 2008),
+ 'firstAdvent' => array('day' => 30, 'month' => 11, 'year' => 2008),
+ 'secondAdvent' => array('day' => 7, 'month' => 12, 'year' => 2008),
+ 'thirdAdvent' => array('day' => 14, 'month' => 12, 'year' => 2008),
+ );
+ $this->testDates2011 = array(
+ 'newYearsDay' => array('day' => 1,
+ 'month' => 1,
+ 'year' => 2011),
+ 'easter' => array('day' => 24,
+ 'month' => 4,
+ 'year' => 2011),
+ 'easterMonday' => array('day' => 25,
+ 'month' => 4,
+ 'year' => 2011),
+ 'dayOfWork' => array('day' => 1,
+ 'month' => 5,
+ 'year' => 2011),
+ 'whitsun' => array('day'=> 12,
+ 'month' => 6,
+ 'year' =>2011),
+ 'whitMonday' => array('day'=> 13,
+ 'month' => 6,
+ 'year' =>2011),
+ 'mariaAscension' => array('day' => 15,
+ 'month' => 8,
+ 'year' => 2011),
+ 'nationalDayAustria' => array('day' => 26,
+ 'month' => 10,
+ 'year' => 2011),
+ 'allSaintsDay' => array('day' => 1,
+ 'month' => 11,
+ 'year' => 2011),
+ // http://christianity.about.com/od/christmas/qt/adventdates2011.htm
+ 'firstAdvent' => array('day' => 27,
+ 'month' => 11,
+ 'year' => 2011),
+ 'secondAdvent' => array('day' => 4,
+ 'month' => 12,
+ 'year' => 2011),
+ 'thirdAdvent' => array('day' => 11,
+ 'month' => 12,
+ 'year' => 2011),
+ 'fourthAdvent' => array('day' => 18,
+ 'month' => 12,
+ 'year' => 2011),
+ 'christmasDay' => array('day' => 25,
+ 'month' => 12,
+ 'year' => 2011),
+ 'boxingDay' => array('day' => 26,
+ 'month' => 12,
+ 'year' => 2011)
+ );
}
/**
- * test holidays for 2007
+ * test holidays for 2005
*
* @access public
* @return void
*/
- function testHolidays2007()
+ function testHolidays2005()
{
- $drv = Date_Holidays::factory('Austria', 2007, 'en_EN');
+ $drv = Date_Holidays::factory('Austria', 2005, 'en_EN');
if (Date_Holidays::isError($drv)) {
$this->fail(helper_get_error_message($drv));
}
- foreach ($this->testDates2007 as $name => $dateInfo) {
+ foreach ($this->testDates2005 as $name => $dateInfo) {
$day = $drv->getHoliday($name);
if (Date_Holidays::isError($day)) {
$this->fail(helper_get_error_message($day));
@@ -162,6 +236,83 @@ function testHolidays2006()
}
}
+ /**
+ * test holidays for 2007
+ *
+ * @access public
+ * @return void
+ */
+ function testHolidays2007()
+ {
+ $drv = Date_Holidays::factory('Austria', 2007, 'en_EN');
+ if (Date_Holidays::isError($drv)) {
+ $this->fail(helper_get_error_message($drv));
+ }
+
+ foreach ($this->testDates2007 as $name => $dateInfo) {
+ $day = $drv->getHoliday($name);
+ if (Date_Holidays::isError($day)) {
+ $this->fail(helper_get_error_message($day));
+ }
+ $this->assertEquals($name, $day->getInternalName());
+ $date = $day->getDate();
+ $this->assertEquals($dateInfo['day'], $date->getDay(), $name);
+ $this->assertEquals($dateInfo['month'], $date->getMonth(), $name);
+ $this->assertEquals($dateInfo['year'], $date->getYear(), $name);
+ }
+ }
+
+ /**
+ * test holidays for 2008
+ *
+ * @access public
+ * @return void
+ */
+ function testHolidays2008()
+ {
+ $drv = Date_Holidays::factory('Austria', 2008, 'en_EN');
+ if (Date_Holidays::isError($drv)) {
+ $this->fail(helper_get_error_message($drv));
+ }
+
+ foreach ($this->testDates2008 as $name => $dateInfo) {
+ $day = $drv->getHoliday($name);
+ if (Date_Holidays::isError($day)) {
+ $this->fail(helper_get_error_message($day));
+ }
+ $this->assertEquals($name, $day->getInternalName());
+ $date = $day->getDate();
+ $this->assertEquals($dateInfo['day'], $date->getDay(), $name);
+ $this->assertEquals($dateInfo['month'], $date->getMonth(), $name);
+ $this->assertEquals($dateInfo['year'], $date->getYear(), $name);
+ }
+ }
+
+ /**
+ * test holidays for 2011
+ *
+ * @access public
+ * @return void
+ */
+ function testHolidays2011()
+ {
+ $drv = Date_Holidays::factory('Austria', 2011, 'en_EN');
+ if (Date_Holidays::isError($drv)) {
+ $this->fail(helper_get_error_message($drv));
+ }
+
+ foreach ($this->testDates2011 as $name => $dateInfo) {
+ $day = $drv->getHoliday($name);
+ if (Date_Holidays::isError($day)) {
+ $this->fail(helper_get_error_message($day));
+ }
+ $this->assertEquals($name, $day->getInternalName());
+ $date = $day->getDate();
+ $this->assertEquals($dateInfo['day'], $date->getDay(), $name);
+ $this->assertEquals($dateInfo['month'], $date->getMonth(), $name);
+ $this->assertEquals($dateInfo['year'], $date->getYear(), $name);
+ }
+ }
}
?>
Please sign in to comment.
Something went wrong with that request. Please try again.