diff options
Diffstat (limited to 'library/WT')
| -rw-r--r-- | library/WT/Date.php | 6 | ||||
| -rw-r--r-- | library/WT/Date/Calendar.php | 38 | ||||
| -rw-r--r-- | library/WT/Date/French.php | 2 | ||||
| -rw-r--r-- | library/WT/Date/Julian.php | 18 | ||||
| -rw-r--r-- | library/WT/Date/Roman.php | 4 |
5 files changed, 35 insertions, 33 deletions
diff --git a/library/WT/Date.php b/library/WT/Date.php index 307e785540..68865d75a5 100644 --- a/library/WT/Date.php +++ b/library/WT/Date.php @@ -82,13 +82,13 @@ class WT_Date { $cal=''; } // A date with a month: DM, M, MY or DMY - if (preg_match('/^(\d?\d?) ?(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC|TSH|CSH|KSL|TVT|SHV|ADR|ADS|NSN|IYR|SVN|TMZ|AAV|ELL|VEND|BRUM|FRIM|NIVO|PLUV|VENT|GERM|FLOR|PRAI|MESS|THER|FRUC|COMP|MUHAR|SAFAR|RABI[AT]|JUMA[AT]|RAJAB|SHAAB|RAMAD|SHAWW|DHUAQ|DHUAH|FARVA|ORDIB|KHORD|TIR|MORDA|SHAHR|MEHR|ABAN|AZAR|DEY|BAHMA|ESFAN) ?((?:\d+(?: B ?C)?|\d\d\d\d \/ \d{1,4})?)$/', $date, $match)) { + if (preg_match('/^(\d?\d?) ?(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC|TSH|CSH|KSL|TVT|SHV|ADR|ADS|NSN|IYR|SVN|TMZ|AAV|ELL|VEND|BRUM|FRIM|NIVO|PLUV|VENT|GERM|FLOR|PRAI|MESS|THER|FRUC|COMP|MUHAR|SAFAR|RABI[AT]|JUMA[AT]|RAJAB|SHAAB|RAMAD|SHAWW|DHUAQ|DHUAH|FARVA|ORDIB|KHORD|TIR|MORDA|SHAHR|MEHR|ABAN|AZAR|DEY|BAHMA|ESFAN) ?((?:\d{1,4}(?: B\.C\.)?|\d\d\d\d\/\d\d)?)$/', $date, $match)) { $d=$match[1]; $m=$match[2]; $y=$match[3]; } else // A date with just a year - if (preg_match('/^(\d+(?: B ?C)?|\d\d\d\d \/ \d{1,4})$/', $date, $match)) { + if (preg_match('/^(\d{1,4}(?: B\.C\.)?|\d\d\d\d\/\d\d)$/', $date, $match)) { $d=''; $m=''; $y=$match[1]; @@ -121,7 +121,7 @@ class WT_Date { } else { if (preg_match('/^(FARVA|ORDIB|KHORD|TIR|MORDA|SHAHR|MEHR|ABAN|AZAR|DEY|BAHMA|ESFAN)$/', $m)) { $cal='@#DJALALI@'; // This is a WT extension - } elseif (preg_match('/^\d+( B ?C)|\d\d\d\d \/ \d{1,4}$/', $y)) { + } elseif (preg_match('/^\d{1,4}( B\.C\.)|\d\d\d\d\/\d\d$/', $y)) { $cal='@#DJULIAN@'; } diff --git a/library/WT/Date/Calendar.php b/library/WT/Date/Calendar.php index cfd4ccb44a..5849283e5a 100644 --- a/library/WT/Date/Calendar.php +++ b/library/WT/Date/Calendar.php @@ -409,7 +409,7 @@ class WT_Date_Calendar { // Functions to extract bits of the date in various formats. Individual calendars // will want to redefine some of these. - private function FormatDayZeros() { + protected function FormatDayZeros() { if ($this->d>9) { return WT_I18N::digits($this->d); } else { @@ -417,23 +417,23 @@ class WT_Date_Calendar { } } - private function FormatDay() { + protected function FormatDay() { return WT_I18N::digits($this->d); } - private function FormatLongWeekday() { + protected function FormatLongWeekday() { return $this->LONG_DAYS_OF_WEEK($this->minJD % static::DAYS_IN_WEEK); } - private function FormatShortWeekday() { + protected function FormatShortWeekday() { return $this->SHORT_DAYS_OF_WEEK($this->minJD % static::DAYS_IN_WEEK); } - private function FormatISOWeekday() { + protected function FormatISOWeekday() { return WT_I18N::digits($this->minJD % 7 + 1); } - private function FormatOrdinalSuffix() { + protected function FormatOrdinalSuffix() { $func="ordinal_suffix_".WT_LOCALE; if (function_exists($func)) return $func($this->d); @@ -441,19 +441,19 @@ class WT_Date_Calendar { return ''; } - private function FormatNumericWeekday() { + protected function FormatNumericWeekday() { return WT_I18N::digits(($this->minJD + 1) % static::DAYS_IN_WEEK); } - private function FormatDayOfYear() { + protected function FormatDayOfYear() { return WT_I18N::digits($this->minJD - $this->YMDtoJD($this->y, 1, 1)); } - private function FormatMonth() { + protected function FormatMonth() { return WT_I18N::digits($this->m); } - private function FormatMonthZeros() { + protected function FormatMonthZeros() { if ($this->m>9) { return WT_I18N::digits($this->m); } else { @@ -461,7 +461,7 @@ class WT_Date_Calendar { } } - private function FormatLongMonth($case='NOMINATIVE') { + protected function FormatLongMonth($case='NOMINATIVE') { switch ($case) { case 'GENITIVE': return $this->NUM_TO_MONTH_GENITIVE ($this->m, $this->IsLeapYear()); case 'NOMINATIVE': return $this->NUM_TO_MONTH_NOMINATIVE ($this->m, $this->IsLeapYear()); @@ -470,17 +470,17 @@ class WT_Date_Calendar { } } - private function FormatShortMonth() { + protected function FormatShortMonth() { return $this->NUM_TO_SHORT_MONTH($this->m, $this->IsLeapYear()); } // 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. - private function FormatShortYear() { + protected function FormatShortYear() { return WT_I18N::digits($this->y); } - private function FormatGedcomDay() { + protected function FormatGedcomDay() { if ($this->d==0) { return ''; } else { @@ -488,11 +488,11 @@ class WT_Date_Calendar { } } - private function FormatGedcomMonth() { + protected function FormatGedcomMonth() { return array_search($this->m, static::$MONTH_ABBREV); } - private function FormatGedcomYear() { + protected function FormatGedcomYear() { if ($this->y==0) { return ''; } else { @@ -500,12 +500,12 @@ class WT_Date_Calendar { } } - private function FormatLongYear() { + protected function FormatLongYear() { return WT_I18N::digits($this->y); } // Calendars with leap-months should redefine this. - private function NextMonth() { + protected function NextMonth() { return array( $this->m==static::MONTHS_IN_YEAR ? $this->NextYear($this->y) : $this->y, ($this->m % static::MONTHS_IN_YEAR)+1 @@ -526,7 +526,7 @@ class WT_Date_Calendar { } // Convert a roman numeral to decimal - private static function RomanToNum($roman) { + protected static function RomanToNum($roman) { static $lookup=array(1000=>'M', '900'=>'CM', '500'=>'D', 400=>'CD', 100=>'C', 90=>'XC', 50=>'L', 40=>'XL', 10=>'X', 9=>'IX', 5=>'V', 4=>'IV', 1=>'I'); $num=0; foreach ($lookup as $key=>$value) diff --git a/library/WT/Date/French.php b/library/WT/Date/French.php index 481791b32f..7c48c6a7e4 100644 --- a/library/WT/Date/French.php +++ b/library/WT/Date/French.php @@ -156,7 +156,7 @@ class WT_Date_French extends WT_Date_Calendar { } // Years were written using roman numerals - function FormatLongYear() { + protected function FormatLongYear() { return $this->NumToRoman($this->y); } } diff --git a/library/WT/Date/Julian.php b/library/WT/Date/Julian.php index d73ef47f35..824de25d46 100644 --- a/library/WT/Date/Julian.php +++ b/library/WT/Date/Julian.php @@ -73,24 +73,26 @@ class WT_Date_Julian extends WT_Date_Calendar { $day=$e-(int)((153*$m+2)/5)+1; $month=$m+3-12*(int)($m/10); $year=$d-4800+(int)($m/10); - if ($year<1) // 0=1BC, -1=2BC, etc. - --$year; + if ($year<1) { + // 0=1BC, -1=2BC, etc. + --$year; + } return array($year, $month, $day); } // Process new-style/old-style years and years BC - function ExtractYear($year) { - if (preg_match('/^(\d\d\d\d) \/ \d{1,4}$/', $year, $match)) { // Assume the first year is correct + public function ExtractYear($year) { + if (preg_match('/^(\d\d\d\d)\/\d{1,4}$/', $year, $match)) { // Assume the first year is correct $this->new_old_style=true; return $match[1]+1; } else - if (preg_match('/^(\d+) b ?c$/', $year, $match)) + if (preg_match('/^(\d+) B\.C\.$/', $year, $match)) return -$match[1]; else return (int)$year; } - function FormatLongYear() { + 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 */ WT_I18N::translate('%s BCE', WT_I18N::digits(-$this->y)); } else { @@ -101,9 +103,9 @@ class WT_Date_Julian extends WT_Date_Calendar { } } - function FormatGedcomYear() { + protected function FormatGedcomYear() { if ($this->y<0) { - return sprintf('%04dB.C.', -$this->y); + return sprintf('%04d B.C.', -$this->y); } else { if ($this->new_old_style) { return sprintf('%04d/%02d', $this->y-1, $this->y % 100); diff --git a/library/WT/Date/Roman.php b/library/WT/Date/Roman.php index 586bd92afb..b1a760781b 100644 --- a/library/WT/Date/Roman.php +++ b/library/WT/Date/Roman.php @@ -37,11 +37,11 @@ if (!defined('WT_WEBTREES')) { class WT_Date_Roman extends WT_Date_Calendar { const CALENDAR_ESCAPE = '@#DROMAN@'; - function FormatGedcomYear() { + protected function FormatGedcomYear() { return sprintf('%04dAUC',$this->y); } - function FormatLongYear() { + protected function FormatLongYear() { return $this->y.'AUC'; } } |
