1
1
Fork 0

Changed according feedback:

- $posted_date should not allow NULL, instead use `?? ''` instead
- this happened in e.g. 2FA app-specific password listing
This commit is contained in:
Roland Häder 2022-09-24 14:11:46 +02:00
parent 66b9cace9f
commit 2773ac9909
Signed by: roland
GPG key ID: C82EDE5DDFA0BA77
2 changed files with 3 additions and 3 deletions

View 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') : '';
});

View file

@ -311,13 +311,13 @@ class Temporal
*
* @return string with relative date
*/
public static function getRelativeDate(string $posted_date = null, string $format = null): string
public static function getRelativeDate(string $posted_date, string $format = null): string
{
$localtime = $posted_date . ' UTC';
$abs = strtotime($localtime);
if (is_null($posted_date) || $posted_date <= DBA::NULL_DATETIME || $abs === false) {
if (empty($posted_date) || $posted_date <= DBA::NULL_DATETIME || $abs === false) {
return DI::l10n()->t('never');
}