diff options
| author | Greg Roach <fisharebest@gmail.com> | 2015-06-08 15:09:08 +0100 |
|---|---|---|
| committer | Greg Roach <fisharebest@gmail.com> | 2015-06-08 21:42:34 +0100 |
| commit | 76692c8b291f16d9251d67f27078779f6737fe7e (patch) | |
| tree | d92ba170d781d60d4fcff107d5a46bad5bdbce4f /app/Date | |
| parent | 238d6f46440eb68ffb982a7af1ec9dd37c8e75d7 (diff) | |
| download | webtrees-76692c8b291f16d9251d67f27078779f6737fe7e.tar.gz webtrees-76692c8b291f16d9251d67f27078779f6737fe7e.tar.bz2 webtrees-76692c8b291f16d9251d67f27078779f6737fe7e.zip | |
PHPDoc
Diffstat (limited to 'app/Date')
| -rw-r--r-- | app/Date/CalendarDate.php | 5 | ||||
| -rw-r--r-- | app/Date/FrenchDate.php | 83 | ||||
| -rw-r--r-- | app/Date/GregorianDate.php | 14 | ||||
| -rw-r--r-- | app/Date/HijriDate.php | 61 | ||||
| -rw-r--r-- | app/Date/JalaliDate.php | 61 | ||||
| -rw-r--r-- | app/Date/JewishDate.php | 88 | ||||
| -rw-r--r-- | app/Date/JulianDate.php | 38 | ||||
| -rw-r--r-- | app/Date/RomanDate.php | 5 |
8 files changed, 290 insertions, 65 deletions
diff --git a/app/Date/CalendarDate.php b/app/Date/CalendarDate.php index 9bb0962d44..dc6125a969 100644 --- a/app/Date/CalendarDate.php +++ b/app/Date/CalendarDate.php @@ -1,6 +1,4 @@ <?php -namespace Fisharebest\Webtrees\Date; - /** * webtrees: online genealogy * Copyright (C) 2015 webtrees development team @@ -15,13 +13,14 @@ namespace Fisharebest\Webtrees\Date; * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +namespace Fisharebest\Webtrees\Date; use FishareBest\ExtCalendar\CalendarInterface; use FishareBest\ExtCalendar\JewishCalendar; use Fisharebest\Webtrees\I18N; /** - * Class CalendarDate - Classes for Gedcom Date/Calendar functionality. + * Classes for Gedcom Date/Calendar functionality. * * CalendarDate is a base class for classes such as GregorianDate, etc. * + All supported calendars have non-zero days/months/years. diff --git a/app/Date/FrenchDate.php b/app/Date/FrenchDate.php index 3dec17d735..707d21b7e3 100644 --- a/app/Date/FrenchDate.php +++ b/app/Date/FrenchDate.php @@ -1,6 +1,4 @@ <?php -namespace Fisharebest\Webtrees\Date; - /** * webtrees: online genealogy * Copyright (C) 2015 webtrees development team @@ -15,24 +13,39 @@ namespace Fisharebest\Webtrees\Date; * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +namespace Fisharebest\Webtrees\Date; use Fisharebest\ExtCalendar\FrenchCalendar; use Fisharebest\Webtrees\I18N; /** - * Class FrenchDate - Definitions for the French Republican calendar + * Definitions for the French Republican calendar */ class FrenchDate extends CalendarDate { - /** {@inheritdoc} */ + /** @var integer[] Convert GEDCOM month names to month numbers */ public static $MONTH_ABBREV = array('' => 0, 'VEND' => 1, 'BRUM' => 2, 'FRIM' => 3, 'NIVO' => 4, 'PLUV' => 5, 'VENT' => 6, 'GERM' => 7, 'FLOR' => 8, 'PRAI' => 9, 'MESS' => 10, 'THER' => 11, 'FRUC' => 12, 'COMP' => 13); - /** {@inheritdoc} */ + /** + * Create a date from either: + * a Julian day number + * day/month/year strings from a GEDCOM date + * another CalendarDate object + * + * @param array|int|CalendarDate $date + */ public function __construct($date) { $this->calendar = new FrenchCalendar; parent::__construct($date); } - /** {@inheritdoc} */ + /** + * Full month name in nominative case. + * + * @param int $month_number + * @param bool $leap_year Some calendars use leap months + * + * @return string + */ public static function monthNameNominativeCase($month_number, $leap_year) { static $translated_month_names; @@ -58,7 +71,14 @@ class FrenchDate extends CalendarDate { return $translated_month_names[$month_number]; } - /** {@inheritdoc} */ + /** + * Full month name in genitive case. + * + * @param int $month_number + * @param bool $leap_year Some calendars use leap months + * + * @return string + */ protected function monthNameGenitiveCase($month_number, $leap_year) { static $translated_month_names; @@ -84,7 +104,14 @@ class FrenchDate extends CalendarDate { return $translated_month_names[$month_number]; } - /** {@inheritdoc} */ + /** + * Full month name in locative case. + * + * @param int $month_number + * @param bool $leap_year Some calendars use leap months + * + * @return string + */ protected function monthNameLocativeCase($month_number, $leap_year) { static $translated_month_names; @@ -110,7 +137,14 @@ class FrenchDate extends CalendarDate { return $translated_month_names[$month_number]; } - /** {@inheritdoc} */ + /** + * Full month name in instrumental case. + * + * @param int $month_number + * @param bool $leap_year Some calendars use leap months + * + * @return string + */ protected function monthNameInstrumentalCase($month_number, $leap_year) { static $translated_month_names; @@ -136,12 +170,25 @@ class FrenchDate extends CalendarDate { return $translated_month_names[$month_number]; } - /** {@inheritdoc} */ + /** + * Abbreviated month name + * + * @param int $month_number + * @param bool $leap_year Some calendars use leap months + * + * @return string + */ protected function monthNameAbbreviated($month_number, $leap_year) { return self::monthNameNominativeCase($month_number, $leap_year); } - /** {@inheritdoc} */ + /** + * Full day of th eweek + * + * @param int $day_number + * + * @return string + */ public function dayNames($day_number) { static $translated_day_names; @@ -163,12 +210,22 @@ class FrenchDate extends CalendarDate { return $translated_day_names[$day_number]; } - /** {@inheritdoc} */ + /** + * Abbreviated day of the week + * + * @param int $day_number + * + * @return string + */ protected function dayNamesAbbreviated($day_number) { return $this->dayNames($day_number); } - /** {@inheritdoc} */ + /** + * Generate the %Y format for a date. + * + * @return string + */ protected function formatLongYear() { return $this->numberToRomanNumerals($this->y); } diff --git a/app/Date/GregorianDate.php b/app/Date/GregorianDate.php index 47902f3582..01d34de736 100644 --- a/app/Date/GregorianDate.php +++ b/app/Date/GregorianDate.php @@ -1,6 +1,4 @@ <?php -namespace Fisharebest\Webtrees\Date; - /** * webtrees: online genealogy * Copyright (C) 2015 webtrees development team @@ -15,14 +13,22 @@ namespace Fisharebest\Webtrees\Date; * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +namespace Fisharebest\Webtrees\Date; use Fisharebest\ExtCalendar\GregorianCalendar; /** - * Class GregorianDate - Definitions for the Gregorian calendar + * Definitions for the Gregorian calendar */ class GregorianDate extends CalendarDate { - /** {@inheritdoc} */ + /** + * Create a date from either: + * a Julian day number + * day/month/year strings from a GEDCOM date + * another CalendarDate object + * + * @param array|int|CalendarDate $date + */ public function __construct($date) { $this->calendar = new GregorianCalendar; parent::__construct($date); diff --git a/app/Date/HijriDate.php b/app/Date/HijriDate.php index f15750c71c..4a04f89691 100644 --- a/app/Date/HijriDate.php +++ b/app/Date/HijriDate.php @@ -1,6 +1,4 @@ <?php -namespace Fisharebest\Webtrees\Date; - /** * webtrees: online genealogy * Copyright (C) 2015 webtrees development team @@ -15,27 +13,42 @@ namespace Fisharebest\Webtrees\Date; * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +namespace Fisharebest\Webtrees\Date; use Fisharebest\ExtCalendar\ArabicCalendar; use Fisharebest\Webtrees\I18N; /** - * Class HijriDate - Definitions for the Hijri calendar. + * Definitions for the Hijri calendar. * * Note that these are "theoretical" dates. * "True" dates are based on local lunar observations, and can be a +/- one day. */ class HijriDate extends CalendarDate { - /** {@inheritdoc} */ + /** @var integer[] Convert GEDCOM month names to month numbers */ public static $MONTH_ABBREV = array('' => 0, 'MUHAR' => 1, 'SAFAR' => 2, 'RABIA' => 3, 'RABIT' => 4, 'JUMAA' => 5, 'JUMAT' => 6, 'RAJAB' => 7, 'SHAAB' => 8, 'RAMAD' => 9, 'SHAWW' => 10, 'DHUAQ' => 11, 'DHUAH' => 12); - /** {@inheritdoc} */ + /** + * Create a date from either: + * a Julian day number + * day/month/year strings from a GEDCOM date + * another CalendarDate object + * + * @param array|int|CalendarDate $date + */ public function __construct($date) { $this->calendar = new ArabicCalendar; parent::__construct($date); } - /** {@inheritdoc} */ + /** + * Full month name in nominative case. + * + * @param int $month_number + * @param bool $leap_year Some calendars use leap months + * + * @return string + */ public static function monthNameNominativeCase($month_number, $leap_year) { static $translated_month_names; @@ -60,7 +73,14 @@ class HijriDate extends CalendarDate { return $translated_month_names[$month_number]; } - /** {@inheritdoc} */ + /** + * Full month name in genitive case. + * + * @param int $month_number + * @param bool $leap_year Some calendars use leap months + * + * @return string + */ protected function monthNameGenitiveCase($month_number, $leap_year) { static $translated_month_names; @@ -85,7 +105,14 @@ class HijriDate extends CalendarDate { return $translated_month_names[$month_number]; } - /** {@inheritdoc} */ + /** + * Full month name in locative case. + * + * @param int $month_number + * @param bool $leap_year Some calendars use leap months + * + * @return string + */ protected function monthNameLocativeCase($month_number, $leap_year) { static $translated_month_names; @@ -110,7 +137,14 @@ class HijriDate extends CalendarDate { return $translated_month_names[$month_number]; } - /** {@inheritdoc} */ + /** + * Full month name in instrumental case. + * + * @param int $month_number + * @param bool $leap_year Some calendars use leap months + * + * @return string + */ protected function monthNameInstrumentalCase($month_number, $leap_year) { static $translated_month_names; @@ -135,7 +169,14 @@ class HijriDate extends CalendarDate { return $translated_month_names[$month_number]; } - /** {@inheritdoc} */ + /** + * Abbreviated month name + * + * @param int $month_number + * @param bool $leap_year Some calendars use leap months + * + * @return string + */ protected function monthNameAbbreviated($month_number, $leap_year) { return self::monthNameNominativeCase($month_number, $leap_year); } diff --git a/app/Date/JalaliDate.php b/app/Date/JalaliDate.php index 355e743f6c..f5274c6d24 100644 --- a/app/Date/JalaliDate.php +++ b/app/Date/JalaliDate.php @@ -1,6 +1,4 @@ <?php -namespace Fisharebest\Webtrees\Date; - /** * webtrees: online genealogy * Copyright (C) 2015 webtrees development team @@ -15,24 +13,39 @@ namespace Fisharebest\Webtrees\Date; * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +namespace Fisharebest\Webtrees\Date; use Fisharebest\ExtCalendar\PersianCalendar; use Fisharebest\Webtrees\I18N; /** - * Class JalaliDate - Definitions for the Jalali calendar + * Definitions for the Jalali calendar */ class JalaliDate extends CalendarDate { - /** {@inheritdoc} */ + /** @var integer[] Convert GEDCOM month names to month numbers */ public static $MONTH_ABBREV = array('' => 0, 'FARVA' => 1, 'ORDIB' => 2, 'KHORD' => 3, 'TIR' => 4, 'MORDA' => 5, 'SHAHR' => 6, 'MEHR' => 7, 'ABAN' => 8, 'AZAR' => 9, 'DEY' => 10, 'BAHMA' => 11, 'ESFAN' => 12); - /** {@inheritdoc} */ + /** + * Create a date from either: + * a Julian day number + * day/month/year strings from a GEDCOM date + * another CalendarDate object + * + * @param array|int|CalendarDate $date + */ public function __construct($date) { $this->calendar = new PersianCalendar; parent::__construct($date); } - /** {@inheritdoc} */ + /** + * Full month name in nominative case. + * + * @param int $month_number + * @param bool $leap_year Some calendars use leap months + * + * @return string + */ public static function monthNameNominativeCase($month_number, $leap_year) { static $translated_month_names; @@ -57,7 +70,14 @@ class JalaliDate extends CalendarDate { return $translated_month_names[$month_number]; } - /** {@inheritdoc} */ + /** + * Full month name in genitive case. + * + * @param int $month_number + * @param bool $leap_year Some calendars use leap months + * + * @return string + */ protected function monthNameGenitiveCase($month_number, $leap_year) { static $translated_month_names; @@ -82,7 +102,14 @@ class JalaliDate extends CalendarDate { return $translated_month_names[$month_number]; } - /** {@inheritdoc} */ + /** + * Full month name in locative case. + * + * @param int $month_number + * @param bool $leap_year Some calendars use leap months + * + * @return string + */ protected function monthNameLocativeCase($month_number, $leap_year) { static $translated_month_names; @@ -107,7 +134,14 @@ class JalaliDate extends CalendarDate { return $translated_month_names[$month_number]; } - /** {@inheritdoc} */ + /** + * Full month name in instrumental case. + * + * @param int $month_number + * @param bool $leap_year Some calendars use leap months + * + * @return string + */ protected function monthNameInstrumentalCase($month_number, $leap_year) { static $translated_month_names; @@ -132,7 +166,14 @@ class JalaliDate extends CalendarDate { return $translated_month_names[$month_number]; } - /** {@inheritdoc} */ + /** + * Abbreviated month name + * + * @param int $month_number + * @param bool $leap_year Some calendars use leap months + * + * @return string + */ protected function monthNameAbbreviated($month_number, $leap_year) { static $translated_month_names; diff --git a/app/Date/JewishDate.php b/app/Date/JewishDate.php index 65cb102ee1..9ec3605619 100644 --- a/app/Date/JewishDate.php +++ b/app/Date/JewishDate.php @@ -1,6 +1,4 @@ <?php -namespace Fisharebest\Webtrees\Date; - /** * webtrees: online genealogy * Copyright (C) 2015 webtrees development team @@ -15,24 +13,36 @@ namespace Fisharebest\Webtrees\Date; * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +namespace Fisharebest\Webtrees\Date; use Fisharebest\ExtCalendar\JewishCalendar; use Fisharebest\Webtrees\I18N; /** - * Class JewishDate - Definitions for the Jewish calendar + * Definitions for the Jewish calendar */ class JewishDate extends CalendarDate { - /** {@inheritdoc} */ + /** @var integer[] Convert GEDCOM month names to month numbers */ public static $MONTH_ABBREV = array('' => 0, 'TSH' => 1, 'CSH' => 2, 'KSL' => 3, 'TVT' => 4, 'SHV' => 5, 'ADR' => 6, 'ADS' => 7, 'NSN' => 8, 'IYR' => 9, 'SVN' => 10, 'TMZ' => 11, 'AAV' => 12, 'ELL' => 13); - /** {@inheritdoc} */ + /** + * Create a date from either: + * a Julian day number + * day/month/year strings from a GEDCOM date + * another CalendarDate object + * + * @param array|int|CalendarDate $date + */ public function __construct($date) { $this->calendar = new JewishCalendar; parent::__construct($date); } - /** {@inheritdoc} */ + /** + * Generate the %j format for a date. + * + * @return string + */ protected function formatDay() { if (WT_LOCALE === 'he' || WT_LOCALE === 'yi') { return $this->calendar->numberToHebrewNumerals($this->d, true); @@ -41,7 +51,14 @@ class JewishDate extends CalendarDate { } } - /** {@inheritdoc} */ + /** + * Generate the %y format for a date. + * + * NOTE Short year is NOT a 2-digit year. It is for calendars such as hebrew + * which have a 3-digit form of 4-digit years. + * + * @return string + */ protected function formatShortYear() { if (WT_LOCALE === 'he' || WT_LOCALE === 'yi') { return $this->calendar->numberToHebrewNumerals($this->y, false); @@ -50,7 +67,11 @@ class JewishDate extends CalendarDate { } } - /** {@inheritdoc} */ + /** + * Generate the %Y format for a date. + * + * @return string + */ protected function formatLongYear() { if (WT_LOCALE === 'he' || WT_LOCALE === 'yi') { return $this->calendar->numberToHebrewNumerals($this->y, true); @@ -59,7 +80,14 @@ class JewishDate extends CalendarDate { } } - /** {@inheritdoc} */ + /** + * Full month name in nominative case. + * + * @param int $month_number + * @param bool $leap_year Some calendars use leap months + * + * @return string + */ public static function monthNameNominativeCase($month_number, $leap_year) { static $translated_month_names; @@ -90,7 +118,14 @@ class JewishDate extends CalendarDate { } } - /** {@inheritdoc} */ + /** + * Full month name in genitive case. + * + * @param int $month_number + * @param bool $leap_year Some calendars use leap months + * + * @return string + */ protected function monthNameGenitiveCase($month_number, $leap_year) { static $translated_month_names; @@ -121,7 +156,14 @@ class JewishDate extends CalendarDate { } } - /** {@inheritdoc} */ + /** + * Full month name in locative case. + * + * @param int $month_number + * @param bool $leap_year Some calendars use leap months + * + * @return string + */ protected function monthNameLocativeCase($month_number, $leap_year) { static $translated_month_names; @@ -152,7 +194,14 @@ class JewishDate extends CalendarDate { } } - /** {@inheritdoc} */ + /** + * Full month name in instrumental case. + * + * @param int $month_number + * @param bool $leap_year Some calendars use leap months + * + * @return string + */ protected function monthNameInstrumentalCase($month_number, $leap_year) { static $translated_month_names; @@ -183,12 +232,23 @@ class JewishDate extends CalendarDate { } } - /** {@inheritdoc} */ + /** + * Abbreviated month name + * + * @param int $month_number + * @param bool $leap_year Some calendars use leap months + * + * @return string + */ protected function monthNameAbbreviated($month_number, $leap_year) { return self::monthNameNominativeCase($month_number, $leap_year); } - /** {@inheritdoc} */ + /** + * Which months follows this one? Calendars with leap-months should provide their own implementation. + * + * @return integer[] + */ protected function nextMonth() { if ($this->m == 6 && !$this->isLeapYear()) { return array($this->y, 8); diff --git a/app/Date/JulianDate.php b/app/Date/JulianDate.php index 47cce69731..023a1c0969 100644 --- a/app/Date/JulianDate.php +++ b/app/Date/JulianDate.php @@ -1,6 +1,4 @@ <?php -namespace Fisharebest\Webtrees\Date; - /** * webtrees: online genealogy * Copyright (C) 2015 webtrees development team @@ -15,25 +13,39 @@ namespace Fisharebest\Webtrees\Date; * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +namespace Fisharebest\Webtrees\Date; use Fisharebest\ExtCalendar\JulianCalendar; use Fisharebest\Webtrees\I18N; /** - * Class JulianDate - Definitions for the Julian Proleptic calendar + * Definitions for the Julian Proleptic calendar * (Proleptic means we extend it backwards, prior to its introduction in 46BC) */ class JulianDate extends CalendarDate { /** @var bool True for dates recorded in new-style/old-style format, e.g. 2 FEB 1743/44 */ private $new_old_style = false; - /** {@inheritdoc} */ + /** + * Create a date from either: + * a Julian day number + * day/month/year strings from a GEDCOM date + * another CalendarDate object + * + * @param array|int|CalendarDate $date + */ public function __construct($date) { $this->calendar = new JulianCalendar; parent::__construct($date); } - /** {@inheritdoc} */ + /** + * Most years are 1 more than the previous, but not always (e.g. 1BC->1AD) + * + * @param int $year + * + * @return int + */ protected function nextYear($year) { if ($year == -1) { return 1; @@ -45,7 +57,9 @@ class JulianDate extends CalendarDate { /** * Process new-style/old-style years and years BC * - * {@inheritdoc} + * @param string $year + * + * @return int */ protected function extractYear($year) { if (preg_match('/^(\d\d\d\d)\/\d{1,4}$/', $year, $match)) { @@ -60,7 +74,11 @@ class JulianDate extends CalendarDate { } } - /** {@inheritdoc} */ + /** + * Generate the %Y format for a date. + * + * @return string + */ protected function formatLongYear() { if ($this->y < 0) { return /* I18N: BCE=Before the Common Era, for Julian years < 0. See http://en.wikipedia.org/wiki/Common_Era */ @@ -75,7 +93,11 @@ class JulianDate extends CalendarDate { } } - /** {@inheritdoc} */ + /** + * Generate the %E format for a date. + * + * @return string + */ protected function formatGedcomYear() { if ($this->y < 0) { return sprintf('%04d B.C.', -$this->y); diff --git a/app/Date/RomanDate.php b/app/Date/RomanDate.php index 07bbe56524..7506f9eacd 100644 --- a/app/Date/RomanDate.php +++ b/app/Date/RomanDate.php @@ -1,6 +1,4 @@ <?php -namespace Fisharebest\Webtrees\Date; - /** * webtrees: online genealogy * Copyright (C) 2015 webtrees development team @@ -15,9 +13,10 @@ namespace Fisharebest\Webtrees\Date; * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +namespace Fisharebest\Webtrees\Date; /** - * Class RomanDate - Definitions for the Roman calendar + * Definitions for the Roman calendar * * The 5.5.1 gedcom spec mentions this calendar, but gives no details of * how it is to be represented.... This class is just a place holder so that |
