Permalink
Browse files

- completed testsuite for common driver methods

- updated Germany driver's language-date (removed "againstNoiseDay" !BC break!)


git-svn-id: http://svn.php.net/repository/pear/packages/Date_Holidays/trunk@195829 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent edbe00c commit c3ffca723fa91ebde06ccf987b8ec93d2cddf69f Carsten Lucke committed Sep 11, 2005
View
@@ -547,12 +547,19 @@ function getHolidayForDate($date, $locale = null, $multiple = false)
* @access public
* @param mixed $start date (timestamp | string | PEAR::Date object)
* @param mixed $end date (timestamp | string | PEAR::Date object)
+ * @param Date_Holidays_Filter $filter filter-object (or an array !DEPRECATED!)
* @param string $locale locale setting that shall be used by this method
* @throws object PEAR_Error DATE_HOLIDAYS_INVALID_DATE, DATE_HOLIDAYS_INVALID_DATE_FORMAT
* @return array an array containing a number of <code>Date_Holidays_Holiday</code> items
*/
- function getHolidaysForDatespan($start, $end, $locale = null)
+ function getHolidaysForDatespan($start, $end, $filter = null, $locale = null)
{
+ if (is_null($filter)) {
+ $filter = &new Date_Holidays_Filter_Blacklist(array());
+ } elseif (is_array($filter)) {
+ $filter = &new Date_Holidays_Filter_Whitelist($filter);
+ }
+
if (!is_a($start, 'Date')) {
$start = &$this->_convertDate($start);
if (Date_Holidays::isError($start)) {
@@ -566,7 +573,8 @@ function getHolidaysForDatespan($start, $end, $locale = null)
}
}
- $isodateStart = mktime(0, 0, 0, $start->getMonth(), $start->getDay(), $start->getYear());
+ $isodateStart = mktime(0, 0, 0, $start->getMonth(), $start->getDay(),
+ $start->getYear());
unset($start);
$isodateEnd = mktime(0, 0, 0, $end->getMonth(), $end->getDay(), $end->getYear());
unset($end);
@@ -584,7 +592,9 @@ function getHolidaysForDatespan($start, $end, $locale = null)
$retval = array();
foreach ($internalNames as $internalName) {
- $retval[] = &$this->getHoliday($internalName, $locale);
+ if ($filter->accept($internalName)) {
+ $retval[] = &$this->getHoliday($internalName, $locale);
+ }
}
return $retval;
@@ -674,7 +684,7 @@ function _addHoliday($internalName, $date, $title)
}
/**
- * Add a localized translation for a holiday's title
+ * Add a localized translation for a holiday's title. Overwrites existing data.
*
* @access protected
* @param string $internalName internal name of an existing holiday
@@ -700,6 +710,7 @@ function _addTranslationForHoliday($internalName, $locale, $title)
/**
* Adds a localized (regrading translation etc.) string-property for a holiday.
+ * Overwrites existing data.
*
* @access public
* @param string internal-name
@@ -767,19 +778,21 @@ function _addStringPropertiesForHoliday($internalName, $locale, $properties)
function addTranslationFile($file, $locale)
{
if (! file_exists($file)) {
- Date_Holidays::raiseError(DATE_HOLIDAYS_LANGUAGEFILE_NOT_FOUND, 'Language-file not found');
+ Date_Holidays::raiseError(DATE_HOLIDAYS_LANGUAGEFILE_NOT_FOUND,
+ 'Language-file not found: ' . $file);
return Date_Holidays::getErrorStack();
}
require_once 'XML/Unserializer.php';
$options = array(
'parseAttributes' => false,
'attributesArray' => false,
- 'keyAttribute' => array('property' => 'id')
+ 'keyAttribute' => array('property' => 'id'),
+ 'forceEnum' => array('holiday')
);
$unserializer = &new XML_Unserializer($options);
- // userialize the document
+ // unserialize the document
$status = $unserializer->unserialize($file, true);
if (PEAR::isError($status)) {
@@ -805,7 +818,8 @@ function addTranslationFile($file, $locale)
function addCompiledTranslationFile($file, $locale)
{
if (! file_exists($file)) {
- Date_Holidays::raiseError(DATE_HOLIDAYS_LANGUAGEFILE_NOT_FOUND, 'Language-file not found');
+ Date_Holidays::raiseError(DATE_HOLIDAYS_LANGUAGEFILE_NOT_FOUND,
+ 'Language-file not found: ' . $file);
return Date_Holidays::getErrorStack();
}
@@ -836,7 +850,7 @@ function _addTranslationData($data, $locale)
foreach ($data['holidays']['holiday'] as $holiday) {
$this->_addTranslationForHoliday($holiday['internal-name'], $locale,
$holiday['translation']);
-
+
if (isset($holiday['properties']) && is_array($holiday['properties'])) {
foreach ($holiday['properties'] as $propId => $propVal) {
$this->_addStringPropertyForHoliday($holiday['internal-name'], $locale,
View
1 TODO
@@ -1,3 +1,4 @@
- improve doc-comments (remove old stuff)
- separate Christian driver into Catholic and Evangelic, let Germany extend none of these but use delegates instead
- build a tool that shows missing translations in language files
+- locale information for holiday objects :: Date_Holidays_Holiday::getLocale()
View
@@ -8,7 +8,6 @@ april1st = 1. April
girlsDay = Girls' Day
earthDay = Internationaler Tag der Erde
beersDay = Tag des deutschen Biers
-againstNoiseDay = Tag gegen Lärm
walpurgisNight = Walpurgisnacht
dayOfWork = Tag der Arbeit
laughingDay = Weltlachtag
View
@@ -1 +1 @@
-a:1:{s:8:"holidays";a:1:{s:7:"holiday";a:38:{i:0;a:2:{s:13:"internal-name";s:11:"newYearsDay";s:11:"translation";s:7:"Neujahr";}i:1;a:2:{s:13:"internal-name";s:13:"valentinesDay";s:11:"translation";s:12:"Valentinstag";}i:2;a:2:{s:13:"internal-name";s:11:"womenFasnet";s:11:"translation";s:15:"Weiberfastnacht";}i:3;a:2:{s:13:"internal-name";s:6:"fasnet";s:11:"translation";s:9:"Fastnacht";}i:4;a:2:{s:13:"internal-name";s:10:"roseMonday";s:11:"translation";s:11:"Rosenmontag";}i:5;a:2:{s:13:"internal-name";s:9:"womensDay";s:11:"translation";s:25:"Internationaler Frauentag";}i:6;a:2:{s:13:"internal-name";s:8:"april1st";s:11:"translation";s:8:"1. April";}i:7;a:2:{s:13:"internal-name";s:8:"girlsDay";s:11:"translation";s:10:"Girls' Day";}i:8;a:2:{s:13:"internal-name";s:8:"earthDay";s:11:"translation";s:28:"Internationaler Tag der Erde";}i:9;a:2:{s:13:"internal-name";s:8:"beersDay";s:11:"translation";s:23:"Tag des deutschen Biers";}i:10;a:2:{s:13:"internal-name";s:15:"againstNoiseDay";s:11:"translation";s:14:"Tag gegen L�rm";}i:11;a:2:{s:13:"internal-name";s:14:"walpurgisNight";s:11:"translation";s:14:"Walpurgisnacht";}i:12;a:2:{s:13:"internal-name";s:9:"dayOfWork";s:11:"translation";s:14:"Tag der Arbeit";}i:13;a:2:{s:13:"internal-name";s:11:"laughingDay";s:11:"translation";s:11:"Weltlachtag";}i:14;a:2:{s:13:"internal-name";s:9:"europeDay";s:11:"translation";s:9:"Europatag";}i:15;a:2:{s:13:"internal-name";s:10:"mothersDay";s:11:"translation";s:9:"Muttertag";}i:16;a:2:{s:13:"internal-name";s:10:"endOfWWar2";s:11:"translation";s:25:"Kriegsende in Deutschland";}i:17;a:2:{s:13:"internal-name";s:10:"fathersDay";s:11:"translation";s:8:"Vatertag";}i:18;a:2:{s:13:"internal-name";s:5:"aiDay";s:11:"translation";s:25:"Amnesty International Tag";}i:19;a:2:{s:13:"internal-name";s:14:"intChildrenDay";s:11:"translation";s:25:"Internationaler Kindertag";}i:20;a:2:{s:13:"internal-name";s:16:"organDonationDay";s:11:"translation";s:19:"Tag der Organspende";}i:21;a:2:{s:13:"internal-name";s:11:"dormouseDay";s:11:"translation";s:14:"Siebenschl�fer";}i:22;a:2:{s:13:"internal-name";s:20:"christopherStreetDay";s:11:"translation";s:22:"Christopher Street Day";}i:23;a:2:{s:13:"internal-name";s:25:"hiroshimaCommemorationDay";s:11:"translation";s:19:"Hiroshima Gedenktag";}i:24;a:2:{s:13:"internal-name";s:24:"augsburgPeaceCelebration";s:11:"translation";s:31:"Friedensfest der Stadt Augsburg";}i:25;a:2:{s:13:"internal-name";s:13:"leftHandedDay";s:11:"translation";s:30:"Internationaler Linksh�ndertag";}i:26;a:2:{s:13:"internal-name";s:10:"antiWarDay";s:11:"translation";s:13:"Antikriegstag";}i:27;a:2:{s:13:"internal-name";s:17:"germanLanguageDay";s:11:"translation";s:25:"Tag der deutschen Sprache";}i:28;a:2:{s:13:"internal-name";s:11:"diabetesDay";s:11:"translation";s:27:"Internationaler Diabetestag";}i:29;a:2:{s:13:"internal-name";s:20:"germanUnificationDay";s:11:"translation";s:25:"Tag der Deutschen Einheit";}i:30;a:2:{s:13:"internal-name";s:12:"librariesDay";s:11:"translation";s:20:"Tag der Bibliotheken";}i:31;a:2:{s:13:"internal-name";s:10:"savingsDay";s:11:"translation";s:11:"Weltspartag";}i:32;a:2:{s:13:"internal-name";s:9:"halloween";s:11:"translation";s:9:"Halloween";}i:33;a:2:{s:13:"internal-name";s:9:"stampsDay";s:11:"translation";s:18:"Tag der Briefmarke";}i:34;a:2:{s:13:"internal-name";s:7:"mensDay";s:11:"translation";s:30:"Internationaler Tag des Mannes";}i:35;a:2:{s:13:"internal-name";s:12:"wallOfBerlin";s:11:"translation";s:28:"Fall der Berliner Mauer 1989";}i:36;a:2:{s:13:"internal-name";s:17:"carnivalBeginning";s:11:"translation";s:20:"Beginn des Karnevals";}i:37;a:2:{s:13:"internal-name";s:13:"dayOfMourning";s:11:"translation";s:14:"Volkstrauertag";}}}}
+a:1:{s:8:"holidays";a:1:{s:7:"holiday";a:37:{i:0;a:2:{s:13:"internal-name";s:11:"newYearsDay";s:11:"translation";s:7:"Neujahr";}i:1;a:2:{s:13:"internal-name";s:13:"valentinesDay";s:11:"translation";s:12:"Valentinstag";}i:2;a:2:{s:13:"internal-name";s:11:"womenFasnet";s:11:"translation";s:15:"Weiberfastnacht";}i:3;a:2:{s:13:"internal-name";s:6:"fasnet";s:11:"translation";s:9:"Fastnacht";}i:4;a:2:{s:13:"internal-name";s:10:"roseMonday";s:11:"translation";s:11:"Rosenmontag";}i:5;a:2:{s:13:"internal-name";s:9:"womensDay";s:11:"translation";s:25:"Internationaler Frauentag";}i:6;a:2:{s:13:"internal-name";s:8:"april1st";s:11:"translation";s:8:"1. April";}i:7;a:2:{s:13:"internal-name";s:8:"girlsDay";s:11:"translation";s:10:"Girls' Day";}i:8;a:2:{s:13:"internal-name";s:8:"earthDay";s:11:"translation";s:28:"Internationaler Tag der Erde";}i:9;a:2:{s:13:"internal-name";s:8:"beersDay";s:11:"translation";s:23:"Tag des deutschen Biers";}i:10;a:2:{s:13:"internal-name";s:14:"walpurgisNight";s:11:"translation";s:14:"Walpurgisnacht";}i:11;a:2:{s:13:"internal-name";s:9:"dayOfWork";s:11:"translation";s:14:"Tag der Arbeit";}i:12;a:2:{s:13:"internal-name";s:11:"laughingDay";s:11:"translation";s:11:"Weltlachtag";}i:13;a:2:{s:13:"internal-name";s:9:"europeDay";s:11:"translation";s:9:"Europatag";}i:14;a:2:{s:13:"internal-name";s:10:"mothersDay";s:11:"translation";s:9:"Muttertag";}i:15;a:2:{s:13:"internal-name";s:10:"endOfWWar2";s:11:"translation";s:25:"Kriegsende in Deutschland";}i:16;a:2:{s:13:"internal-name";s:10:"fathersDay";s:11:"translation";s:8:"Vatertag";}i:17;a:2:{s:13:"internal-name";s:5:"aiDay";s:11:"translation";s:25:"Amnesty International Tag";}i:18;a:2:{s:13:"internal-name";s:14:"intChildrenDay";s:11:"translation";s:25:"Internationaler Kindertag";}i:19;a:2:{s:13:"internal-name";s:16:"organDonationDay";s:11:"translation";s:19:"Tag der Organspende";}i:20;a:2:{s:13:"internal-name";s:11:"dormouseDay";s:11:"translation";s:14:"Siebenschl�fer";}i:21;a:2:{s:13:"internal-name";s:20:"christopherStreetDay";s:11:"translation";s:22:"Christopher Street Day";}i:22;a:2:{s:13:"internal-name";s:25:"hiroshimaCommemorationDay";s:11:"translation";s:19:"Hiroshima Gedenktag";}i:23;a:2:{s:13:"internal-name";s:24:"augsburgPeaceCelebration";s:11:"translation";s:31:"Friedensfest der Stadt Augsburg";}i:24;a:2:{s:13:"internal-name";s:13:"leftHandedDay";s:11:"translation";s:30:"Internationaler Linksh�ndertag";}i:25;a:2:{s:13:"internal-name";s:10:"antiWarDay";s:11:"translation";s:13:"Antikriegstag";}i:26;a:2:{s:13:"internal-name";s:17:"germanLanguageDay";s:11:"translation";s:25:"Tag der deutschen Sprache";}i:27;a:2:{s:13:"internal-name";s:11:"diabetesDay";s:11:"translation";s:27:"Internationaler Diabetestag";}i:28;a:2:{s:13:"internal-name";s:20:"germanUnificationDay";s:11:"translation";s:25:"Tag der Deutschen Einheit";}i:29;a:2:{s:13:"internal-name";s:12:"librariesDay";s:11:"translation";s:20:"Tag der Bibliotheken";}i:30;a:2:{s:13:"internal-name";s:10:"savingsDay";s:11:"translation";s:11:"Weltspartag";}i:31;a:2:{s:13:"internal-name";s:9:"halloween";s:11:"translation";s:9:"Halloween";}i:32;a:2:{s:13:"internal-name";s:9:"stampsDay";s:11:"translation";s:18:"Tag der Briefmarke";}i:33;a:2:{s:13:"internal-name";s:7:"mensDay";s:11:"translation";s:30:"Internationaler Tag des Mannes";}i:34;a:2:{s:13:"internal-name";s:12:"wallOfBerlin";s:11:"translation";s:28:"Fall der Berliner Mauer 1989";}i:35;a:2:{s:13:"internal-name";s:17:"carnivalBeginning";s:11:"translation";s:20:"Beginn des Karnevals";}i:36;a:2:{s:13:"internal-name";s:13:"dayOfMourning";s:11:"translation";s:14:"Volkstrauertag";}}}}
View
@@ -54,11 +54,6 @@
</holiday>
<holiday>
- <internal-name>againstNoiseDay</internal-name>
- <translation>Tag gegen Lärm</translation>
- </holiday>
-
- <holiday>
<internal-name>walpurgisNight</internal-name>
<translation>Walpurgisnacht</translation>
</holiday>
View
@@ -7,7 +7,6 @@ april1st = April Fools
girlsDay = Girls' Day
earthDay = International Earth' Day
beersDay = German Beer's Day
-againstNoiseDay = Day against Noise
walpurgisNight = Walpurgis Night
dayOfWork = Labor Day
laughingDay = World's Laughing Day
Oops, something went wrong.

0 comments on commit c3ffca7

Please sign in to comment.