summaryrefslogtreecommitdiff
path: root/library/WT/Date
diff options
context:
space:
mode:
Diffstat (limited to 'library/WT/Date')
-rw-r--r--library/WT/Date/Calendar.php42
-rw-r--r--library/WT/Date/Jewish.php27
-rw-r--r--library/WT/Date/Julian.php5
3 files changed, 39 insertions, 35 deletions
diff --git a/library/WT/Date/Calendar.php b/library/WT/Date/Calendar.php
index 6630205e61..09e9e9385d 100644
--- a/library/WT/Date/Calendar.php
+++ b/library/WT/Date/Calendar.php
@@ -82,7 +82,7 @@ class WT_Date_Calendar {
// Construct from an array (of three gedcom-style strings: "1900", "FEB", "4")
if (is_array($date)) {
- $this->d = (int)$date[2];
+ $this->d = (int) $date[2];
if (array_key_exists($date[1], static::$MONTH_ABBREV)) {
$this->m = static::$MONTH_ABBREV[$date[1]];
} else {
@@ -119,7 +119,7 @@ class WT_Date_Calendar {
$jd = $date->calendar->ymdToJd($today[0], $date->m, $date->d == 0 ? $today[2] : $date->d);
} else {
// Complete date
- $jd = (int)(($date->maxJD + $date->minJD) / 2);
+ $jd = (int) (($date->maxJD + $date->minJD) / 2);
}
list($this->y, $this->m, $this->d) = $this->calendar->jdToYmd($jd);
// New date has same precision as original date
@@ -410,7 +410,7 @@ class WT_Date_Calendar {
* @return integer
*/
protected function extractYear($year) {
- return (int)$year;
+ return (int) $year;
}
/**
@@ -649,7 +649,7 @@ class WT_Date_Calendar {
$format = str_replace($match, $this->daysInMonth(), $format);
break;
case '%L':
- $format = str_replace($match, (int)$this->isLeapYear(), $format);
+ $format = str_replace($match, (int) $this->isLeapYear(), $format);
break;
case '%Y':
$format = str_replace($match, $this->formatLongYear(), $format);
@@ -892,7 +892,7 @@ class WT_Date_Calendar {
protected static function numberToRomanNumerals($number) {
if ($number < 1) {
// Cannot convert zero/negative numbers
- return (string)$number;
+ return (string) $number;
}
$roman = '';
foreach (self::$roman_numerals as $key => $value) {
@@ -957,24 +957,22 @@ class WT_Date_Calendar {
* @return string
*/
public function calendarUrl($date_format) {
- $URL = 'calendar.php?cal=' . rawurlencode(static::CALENDAR_ESCAPE);
- $action = 'year';
- if (strpos($date_format, 'Y') !== false || strpos($date_format, 'y') !== false) {
- $URL .= '&amp;year=' . $this->formatGedcomYear();
- }
- if (strpos($date_format, 'F') !== false || strpos($date_format, 'M') !== false || strpos($date_format, 'm') !== false || strpos($date_format, 'n') !== false) {
- $URL .= '&amp;month=' . $this->formatGedcomMonth();
- if ($this->m > 0) {
- $action = 'calendar';
- }
- }
- if (strpos($date_format, 'd') !== false || strpos($date_format, 'D') !== false || strpos($date_format, 'j') !== false) {
- $URL .= '&amp;day=' . $this->formatGedcomDay();
- if ($this->d > 0) {
- $action = 'today';
- }
+ if (strpbrk($date_format, 'dDj') && $this->d) {
+ // If the format includes a day, and the date also includes a day, then use the day view
+ $view = 'day';
+ } elseif (strpbrk($date_format, 'FMmn') && $this->m) {
+ // If the format includes a month, and the date also includes a month, then use the month view
+ $view = 'month';
+ } else {
+ // Use the year view
+ $view = 'year';
}
- return $URL . '&amp;action=' . $action;
+ return
+ 'calendar.php?cal=' . rawurlencode(static::CALENDAR_ESCAPE) .
+ '&amp;year=' . $this->formatGedcomYear() .
+ '&amp;month=' . $this->formatGedcomMonth() .
+ '&amp;day=' . $this->formatGedcomDay() .
+ '&amp;view=' . $view;
}
}
diff --git a/library/WT/Date/Jewish.php b/library/WT/Date/Jewish.php
index 8fba7faa06..9837918e97 100644
--- a/library/WT/Date/Jewish.php
+++ b/library/WT/Date/Jewish.php
@@ -237,30 +237,32 @@ class WT_Date_Jewish extends WT_Date_Calendar {
$shortYear = $num % 1000; //discard thousands
//next check for all possible single Hebrew digit years
$singleDigitYear = ($shortYear < 11 || ($shortYear < 100 && $shortYear % 10 == 0) || ($shortYear <= 400 && $shortYear % 100 == 0));
- $thousands = (int)($num / 1000); //get # thousands
+ $thousands = (int) ($num / 1000); //get # thousands
$sb = "";
//append thousands to String
- if ($num % 1000 == 0) { // in year is 5000, 4000 etc
+ if ($num % 1000 == 0) {
+ // in year is 5000, 4000 etc
$sb .= $jOnes[$thousands];
$sb .= self::GERSH;
$sb .= " ";
$sb .= self::ALAFIM; //add # of thousands plus word thousand (overide alafim boolean)
- } else if ($DISPLAY_JEWISH_THOUSANDS) { // if alafim boolean display thousands
+ } elseif ($DISPLAY_JEWISH_THOUSANDS) {
+ // if alafim boolean display thousands
$sb .= $jOnes[$thousands];
$sb .= self::GERSH; //append thousands quote
$sb .= " ";
}
$num = $num % 1000; //remove 1000s
- $hundreds = (int)($num / 100); // # of hundreds
+ $hundreds = (int) ($num / 100); // # of hundreds
$sb .= $jHundreds[$hundreds]; //add hundreds to String
$num = $num % 100; //remove 100s
- if ($num == 15) { //special case 15
+ if ($num == 15) {
$sb .= $tavTaz[0];
- } else if ($num == 16) { //special case 16
+ } else if ($num == 16) {
$sb .= $tavTaz[1];
} else {
- $tens = (int)($num / 10);
- if ($num % 10 == 0) { // if evenly divisable by 10
+ $tens = (int) ($num / 10);
+ if ($num % 10 == 0) {
if ($singleDigitYear == false) {
$sb .= $jTenEnds[$tens]; // use end letters so that for example 5750 will end with an end nun
} else {
@@ -273,11 +275,14 @@ class WT_Date_Jewish extends WT_Date_Calendar {
}
}
if ($singleDigitYear == true) {
- $sb .= self::GERSH; //append single quote
- } else { // append double quote before last digit
+ // Append single quote
+ $sb .= self::GERSH;
+ } else {
+ // Append double quote before last digit
$pos1 = strlen($sb) - 2;
$sb = substr($sb, 0, $pos1) . self::GERSHAYIM . substr($sb, $pos1);
- $sb = str_replace(self::GERSHAYIM . self::GERSHAYIM, self::GERSHAYIM, $sb); //replace double gershayim with single instance
+ // Replace double gershayim with single instance
+ $sb = str_replace(self::GERSHAYIM . self::GERSHAYIM, self::GERSHAYIM, $sb);
}
return $sb;
diff --git a/library/WT/Date/Julian.php b/library/WT/Date/Julian.php
index bd31e1bee3..068a12c33e 100644
--- a/library/WT/Date/Julian.php
+++ b/library/WT/Date/Julian.php
@@ -55,14 +55,15 @@ class WT_Date_Julian extends WT_Date_Calendar {
* {@inheritdoc}
*/
protected function extractYear($year) {
- if (preg_match('/^(\d\d\d\d)\/\d{1,4}$/', $year, $match)) { // Assume the first year is correct
+ 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)) {
return -$match[1];
} else {
- return (int)$year;
+ return (int) $year;
}
}