X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FTemporal.php;h=ec71ab5e963e4604f7c8c072ff1c11295f7bc3b7;hb=cc8a6c85ae939c0fc9258d7a11276bc7c2e59bc0;hp=140d3db37a38c7353ef17faa6d2ce31a8ca17ba4;hpb=352da9bcf393e4be886cda3bfe7db7d80365fef2;p=friendica.git diff --git a/src/Util/Temporal.php b/src/Util/Temporal.php index 140d3db37a..ec71ab5e96 100644 --- a/src/Util/Temporal.php +++ b/src/Util/Temporal.php @@ -8,15 +8,11 @@ namespace Friendica\Util; use DateTime; use DateTimeZone; -use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Core\PConfig; use Friendica\Core\Renderer; use Friendica\Database\DBA; -require_once 'boot.php'; -require_once 'include/text.php'; - /** * @brief Temporal class */ @@ -102,12 +98,13 @@ class Temporal * arguments follow convention as other field_* template array: * 'name', 'label', $value, 'help' * - * @param string $name Name of the selector - * @param string $label Label for the selector + * @param string $name Name of the selector + * @param string $label Label for the selector * @param string $current Timezone - * @param string $help Help text + * @param string $help Help text * * @return string Parsed HTML + * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ public static function getTimezoneField($name = 'timezone', $label = '', $current = 'America/Los_Angeles', $help = '') { @@ -126,10 +123,11 @@ class Temporal * * @param string $dob Date of Birth * @return string Formatted HTML + * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ public static function getDateofBirthField($dob) { - $a = get_app(); + $a = \get_app(); list($year, $month, $day) = sscanf($dob, '%4d-%2d-%2d'); @@ -160,12 +158,13 @@ class Temporal /** * @brief Returns a date selector * - * @param string $min Unix timestamp of minimum date - * @param string $max Unix timestap of maximum date - * @param string $default Unix timestamp of default date - * @param string $id ID and name of datetimepicker (defaults to "datetimepicker") + * @param DateTime $min Minimum date + * @param DateTime $max Maximum date + * @param DateTime $default Default date + * @param string $id ID and name of datetimepicker (defaults to "datetimepicker") * * @return string Parsed HTML output. + * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ public static function getDateField($min, $max, $default, $id = 'datepicker') { @@ -180,6 +179,7 @@ class Temporal * @param string $id ID and name of datetimepicker (defaults to "timepicker") * * @return string Parsed HTML output. + * @throws \Exception */ public static function getTimeField($h, $m, $id = 'timepicker') { @@ -192,6 +192,7 @@ class Temporal * @param DateTime $minDate Minimum date * @param DateTime $maxDate Maximum date * @param DateTime $defaultDate Default date + * @param $label * @param string $id Id and name of datetimepicker (defaults to "datetimepicker") * @param bool $pickdate true to show date picker (default) * @param bool $picktime true to show time picker (default) @@ -201,7 +202,8 @@ class Temporal * * @return string Parsed HTML output. * - * @todo Once browser support is better this could probably be replaced with + * @throws \Friendica\Network\HTTPException\InternalServerErrorException + * @todo Once browser support is better this could probably be replaced with * native HTML5 date picker. */ public static function getDateTimeField( @@ -351,11 +353,12 @@ class Temporal * and become a year older. If you wish me happy birthday on January 1 * (San Bruno time), you'll be a day late. * - * @param string $dob Date of Birth - * @param string $owner_tz (optional) Timezone of the person of interest + * @param string $dob Date of Birth + * @param string $owner_tz (optional) Timezone of the person of interest * @param string $viewer_tz (optional) Timezone of the person viewing * * @return int Age in years + * @throws \Exception */ public static function getAgeByTimezone($dob, $owner_tz = '', $viewer_tz = '') { @@ -407,6 +410,7 @@ class Temporal * @param int $m Month (1=January, 12=December) * * @return string day 0 = Sunday through 6 = Saturday + * @throws \Exception */ private static function getFirstDayInMonth($y, $m) { @@ -423,14 +427,15 @@ class Temporal * altering td class. * Months count from 1. * - * @param int $y Year - * @param int $m Month + * @param int $y Year + * @param int $m Month * @param array $links (default null) * @param string $class * * @return string * - * @todo Provide (prev, next) links, define class variations for different size calendars + * @throws \Exception + * @todo Provide (prev, next) links, define class variations for different size calendars */ public static function getCalendarTable($y = 0, $m = 0, $links = null, $class = '') { @@ -481,7 +486,7 @@ class Temporal $o .= ""; $day = str_replace(' ', ' ', sprintf('%2.2d', $d)); if ($started) { - if (x($links, $d) !== false) { + if (isset($links[$d])) { $o .= "$day"; } else { $o .= $day;