]> git.mxchange.org Git - friendica.git/commitdiff
Changed:
authorRoland Häder <roland@mxchange.org>
Tue, 18 Oct 2022 16:20:08 +0000 (18:20 +0200)
committerRoland Häder <roland@mxchange.org>
Tue, 18 Oct 2022 16:21:45 +0000 (18:21 +0200)
- re-added `null` again https://github.com/friendica/friendica/pull/11900#discussion_r979248182
- removed null coalescing operator

src/Security/TwoFactor/Model/AppSpecificPassword.php
src/Util/Temporal.php

index d9843756542a4d62db9c637949d65b990385f959..6d1ef0bdcc8e5b9a09f3f1551e38812d484828e7 100644 (file)
@@ -86,7 +86,7 @@ class AppSpecificPassword
                $appSpecificPasswords = DBA::toArray($appSpecificPasswordsStmt);
 
                array_walk($appSpecificPasswords, function (&$value) {
-                       $value['ago']   = Temporal::getRelativeDate($value['last_used'] ?? '');
+                       $value['ago']   = Temporal::getRelativeDate($value['last_used']);
                        $value['utc']   = $value['last_used'] ? DateTimeFormat::utc($value['last_used'], 'c') : '';
                        $value['local'] = $value['last_used'] ? DateTimeFormat::local($value['last_used'], 'r') : '';
                });
index 74389c44b52b5eea3f1c6c3be2afbd2fdd907149..cc6a078fe176020c87620bf0e33e0f2ad258ad6e 100644 (file)
@@ -311,13 +311,16 @@ class Temporal
         *
         * @return string with relative date
         */
-       public static function getRelativeDate(string $posted_date, string $format = null): string
+       public static function getRelativeDate(string $posted_date = null, string $format = null): string
        {
-               $localtime = $posted_date . ' UTC';
+               if (empty($posted_date) || $posted_date <= DBA::NULL_DATETIME) {
+                       return DI::l10n()->t('never');
+               }
 
+               $localtime = $posted_date . ' UTC';
                $abs = strtotime($localtime);
 
-               if (empty($posted_date) || $posted_date <= DBA::NULL_DATETIME || $abs === false) {
+               if ($abs === false) {
                        return DI::l10n()->t('never');
                }