From 4c7e7c5883fdd533e26b17d302a0b76dfd6ba928 Mon Sep 17 00:00:00 2001 From: evavirseda Date: Fri, 27 Dec 2024 10:39:45 +0100 Subject: [PATCH 1/2] feat: improve date/time format --- .../components/Dialogs/vesting/VestingScheduleBox.tsx | 10 ++++++++-- .../components/transactions/TransactionTile.tsx | 7 ++++--- apps/wallet-dashboard/lib/utils/time.ts | 5 ----- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/apps/wallet-dashboard/components/Dialogs/vesting/VestingScheduleBox.tsx b/apps/wallet-dashboard/components/Dialogs/vesting/VestingScheduleBox.tsx index d9a93fc8d7c..dc01cd01129 100644 --- a/apps/wallet-dashboard/components/Dialogs/vesting/VestingScheduleBox.tsx +++ b/apps/wallet-dashboard/components/Dialogs/vesting/VestingScheduleBox.tsx @@ -3,7 +3,7 @@ import { useGetCurrentEpochStartTimestamp } from '@/hooks'; import { DisplayStats, DisplayStatsType } from '@iota/apps-ui-kit'; -import { useFormatCoin } from '@iota/core'; +import { formatDate, useFormatCoin } from '@iota/core'; import { IOTA_TYPE_ARG } from '@iota/iota-sdk/utils'; import { LockLocked } from '@iota/ui-icons'; @@ -20,9 +20,15 @@ export function VestingScheduleBox({ const { data: currentEpochMs } = useGetCurrentEpochStartTimestamp(); const isLocked = expirationTimestampMs > Number(currentEpochMs); + const transactionDate = formatDate(Number(expirationTimestampMs), [ + 'month', + 'day', + 'hour', + 'minute', + ]); return ( } diff --git a/apps/wallet-dashboard/components/transactions/TransactionTile.tsx b/apps/wallet-dashboard/components/transactions/TransactionTile.tsx index 0c76c27ceb1..a128f3c1292 100644 --- a/apps/wallet-dashboard/components/transactions/TransactionTile.tsx +++ b/apps/wallet-dashboard/components/transactions/TransactionTile.tsx @@ -5,7 +5,6 @@ import React, { useState } from 'react'; import TransactionIcon from './TransactionIcon'; -import formatTimestamp from '@/lib/utils/time'; import { ExtendedTransaction, TransactionState } from '@/lib/interfaces'; import { Card, @@ -18,7 +17,7 @@ import { CardActionType, Dialog, } from '@iota/apps-ui-kit'; -import { useFormatCoin, getLabel, useTransactionSummary } from '@iota/core'; +import { useFormatCoin, getLabel, useTransactionSummary, formatDate } from '@iota/core'; import { IOTA_TYPE_ARG } from '@iota/iota-sdk/utils'; import { useCurrentAccount } from '@iota/dapp-kit'; import { TransactionDetailsLayout } from '../Dialogs/transaction/TransactionDetailsLayout'; @@ -47,7 +46,9 @@ export function TransactionTile({ transaction }: TransactionTileProps): JSX.Elem setOpen(true); } - const transactionDate = transaction?.timestamp && formatTimestamp(transaction.timestamp); + const transactionDate = + transaction?.timestamp && + formatDate(Number(transaction?.timestamp), ['month', 'day', 'hour', 'minute']); return ( <> diff --git a/apps/wallet-dashboard/lib/utils/time.ts b/apps/wallet-dashboard/lib/utils/time.ts index 8c66df0c883..9df8d1969f0 100644 --- a/apps/wallet-dashboard/lib/utils/time.ts +++ b/apps/wallet-dashboard/lib/utils/time.ts @@ -1,11 +1,6 @@ // Copyright (c) 2024 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -export default function formatTimestamp(timeStamp: number): string { - const date = new Date(timeStamp); - return new Intl.DateTimeFormat('en-US').format(date); -} - export function parseTimestamp(timestampMs: string): number { const timestamp = parseInt(timestampMs, 10); if (!Number.isFinite(timestamp)) { From ec31f29876a70a4755637ac3eea372d7a822dab3 Mon Sep 17 00:00:00 2001 From: evavirseda Date: Fri, 27 Dec 2024 10:41:07 +0100 Subject: [PATCH 2/2] feat: add year --- .../components/Dialogs/vesting/VestingScheduleBox.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/wallet-dashboard/components/Dialogs/vesting/VestingScheduleBox.tsx b/apps/wallet-dashboard/components/Dialogs/vesting/VestingScheduleBox.tsx index dc01cd01129..d8d9dcdb14b 100644 --- a/apps/wallet-dashboard/components/Dialogs/vesting/VestingScheduleBox.tsx +++ b/apps/wallet-dashboard/components/Dialogs/vesting/VestingScheduleBox.tsx @@ -21,6 +21,7 @@ export function VestingScheduleBox({ const isLocked = expirationTimestampMs > Number(currentEpochMs); const transactionDate = formatDate(Number(expirationTimestampMs), [ + 'year', 'month', 'day', 'hour',