1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Return an empty string when date is not provided [Date display utils] (#11831)

This commit is contained in:
ryanml 2021-08-13 08:22:12 -07:00
parent f5f923d208
commit b7bab56a04
2 changed files with 7 additions and 1 deletions

View File

@ -16,6 +16,9 @@ import { toChecksumHexAddress } from '../../../shared/modules/hexstring-utils';
// formatData :: ( date: <Unix Timestamp> ) -> String
export function formatDate(date, format = "M/d/y 'at' T") {
if (!date) {
return '';
}
return DateTime.fromMillis(date).toFormat(format);
}
@ -24,6 +27,9 @@ export function formatDateWithYearContext(
formatThisYear = 'MMM d',
fallback = 'MMM d, y',
) {
if (!date) {
return '';
}
const dateTime = DateTime.fromMillis(date);
const now = DateTime.local();
return dateTime.toFormat(

View File

@ -80,7 +80,7 @@ export function useTransactionDisplayData(transactionGroup) {
const primaryValue = primaryTransaction.txParams?.value;
let prefix = '-';
const date = formatDateWithYearContext(initialTransaction.time || 0);
const date = formatDateWithYearContext(initialTransaction.time);
let subtitle;
let subtitleContainsOrigin = false;
let recipientAddress = to;