X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FTemporal.php;h=acafb66ab60538949a9b0cacd2540b19b2bc7382;hb=e1863951986ba5be173758324a00652bc5af870c;hp=6a331104eec74caaf50f62de5c551aedb85c52a4;hpb=1de3960e267a8d298348fbca18cf1be1f6a20f7a;p=friendica.git diff --git a/src/Util/Temporal.php b/src/Util/Temporal.php index 6a331104ee..acafb66ab6 100644 --- a/src/Util/Temporal.php +++ b/src/Util/Temporal.php @@ -1,57 +1,75 @@ . + * */ namespace Friendica\Util; use DateTime; use DateTimeZone; -use Friendica\Core\L10n; -use Friendica\Core\PConfig; use Friendica\Core\Renderer; use Friendica\Database\DBA; +use Friendica\DI; +use Friendica\Util\Clock\SystemClock; +use Psr\Clock\ClockInterface; /** - * @brief Temporal class + * Temporal class */ class Temporal { /** - * @brief Two-level sort for timezones. + * Two-level sort for timezones. * * @param string $a * @param string $b + * * @return int */ - private static function timezoneCompareCallback($a, $b) + private static function timezoneCompareCallback(string $a, string $b): int { if (strstr($a, '/') && strstr($b, '/')) { - if (L10n::t($a) == L10n::t($b)) { + if (DI::l10n()->t($a) == DI::l10n()->t($b)) { return 0; } - return (L10n::t($a) < L10n::t($b)) ? -1 : 1; + return (DI::l10n()->t($a) < DI::l10n()->t($b)) ? -1 : 1; } if (strstr($a, '/')) { return -1; } elseif (strstr($b, '/')) { return 1; - } elseif (L10n::t($a) == L10n::t($b)) { + } elseif (DI::l10n()->t($a) == DI::l10n()->t($b)) { return 0; } - return (L10n::t($a) < L10n::t($b)) ? -1 : 1; + return (DI::l10n()->t($a) < DI::l10n()->t($b)) ? -1 : 1; } /** - * @brief Emit a timezone selector grouped (primarily) by continent + * Emit a timezone selector grouped (primarily) by continent * * @param string $current Timezone + * * @return string Parsed HTML output */ - public static function getTimezoneSelect($current = 'America/Los_Angeles') + public static function getTimezoneSelect(string $current = 'America/Los_Angeles'): string { $timezone_identifiers = DateTimeZone::listIdentifiers(); @@ -67,7 +85,7 @@ class Temporal $o .= ''; } $continent = $ex[0]; - $o .= ''; + $o .= ''; } if (count($ex) > 2) { $city = substr($value, strpos($value, '/') + 1); @@ -76,13 +94,13 @@ class Temporal } } else { $city = $ex[0]; - if ($continent != L10n::t('Miscellaneous')) { + if ($continent != DI::l10n()->t('Miscellaneous')) { $o .= ''; - $continent = L10n::t('Miscellaneous'); - $o .= ''; + $continent = DI::l10n()->t('Miscellaneous'); + $o .= ''; } } - $city = str_replace('_', ' ', L10n::t($city)); + $city = str_replace('_', ' ', DI::l10n()->t($city)); $selected = (($value == $current) ? " selected=\"selected\" " : ""); $o .= ""; } @@ -91,7 +109,7 @@ class Temporal } /** - * @brief Generating a Timezone selector + * Generating a Timezone selector * * Return a select using 'field_select_raw' template, with timezones * grouped (primarily) by continent @@ -106,7 +124,7 @@ class Temporal * @return string Parsed HTML * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function getTimezoneField($name = 'timezone', $label = '', $current = 'America/Los_Angeles', $help = '') + public static function getTimezoneField(string $name = 'timezone', string $label = '', string $current = 'America/Los_Angeles', string $help = ''): string { $options = self::getTimezoneSelect($current); $options = str_replace('