Handle null value for last_used fields in TrustedBrowsers and AppSpecificPassword

- Remove obsolete reference to DBA::NULL_DATETIME
This commit is contained in:
Hypolite Petovan 2022-01-22 21:10:20 -05:00
parent 52b119cba3
commit 1a4ec00fec
2 changed files with 9 additions and 11 deletions

View file

@ -111,8 +111,8 @@ class Trusted extends BaseSettings
'created_utc' => DateTimeFormat::utc($trustedBrowser->created, 'c'),
'created_local' => DateTimeFormat::local($trustedBrowser->created, 'r'),
'last_used_ago' => Temporal::getRelativeDate($trustedBrowser->last_used),
'last_used_utc' => DateTimeFormat::utc($trustedBrowser->last_used, 'c'),
'last_used_local' => DateTimeFormat::local($trustedBrowser->last_used, 'r'),
'last_used_utc' => $trustedBrowser->last_used ? DateTimeFormat::utc($trustedBrowser->last_used, 'c') : '',
'last_used_local' => $trustedBrowser->last_used ? DateTimeFormat::local($trustedBrowser->last_used, 'r') : '',
];
$result = $parser->parse($trustedBrowser->user_agent);

View file

@ -86,11 +86,9 @@ class AppSpecificPassword
$appSpecificPasswords = DBA::toArray($appSpecificPasswordsStmt);
array_walk($appSpecificPasswords, function (&$value) {
$last_used = $value['last_used'] ?? DBA::NULL_DATETIME;
$value['ago'] = Temporal::getRelativeDate($last_used);
$value['utc'] = DateTimeFormat::utc($last_used, 'c');
$value['local'] = DateTimeFormat::local($last_used, 'r');
$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') : '';
});
return $appSpecificPasswords;