diff --git a/packages/frontend/src/utils/formatting/formatTimestamp.ts b/packages/frontend/src/utils/formatting/formatTimestamp.ts index 15e0dae6d..76cccbfac 100644 --- a/packages/frontend/src/utils/formatting/formatTimestamp.ts +++ b/packages/frontend/src/utils/formatting/formatTimestamp.ts @@ -1,22 +1,22 @@ import { Timestamp } from '@explorer/types' -export function formatTimestamp(timestamp: Timestamp, type: 'local' | 'utc') { - const { datePart, timePart } = formatTimestampParts(timestamp, type) +// Right now we treat every timestamp as UTC because we are using SSR and there is currently no way to get the user's timezone +// If we ever add a way to get the user's timezone, we can add a 'local' type and retrieve the timezone from the headers or smth + +export function formatTimestamp(timestamp: Timestamp) { + const { datePart, timePart } = formatTimestampParts(timestamp) return `${datePart} ${timePart}` } -export function formatTimestampParts( - timestamp: Timestamp, - type: 'local' | 'utc' -) { +export function formatTimestampParts(timestamp: Timestamp) { const date = new Date(Number(timestamp)) - const year = type === 'local' ? date.getFullYear() : date.getUTCFullYear() - const month = type === 'local' ? date.getMonth() + 1 : date.getUTCMonth() + 1 - const day = type === 'local' ? date.getDate() : date.getUTCDate() - const hour = type === 'local' ? date.getHours() : date.getUTCHours() - const minute = type === 'local' ? date.getMinutes() : date.getUTCMinutes() - const second = type === 'local' ? date.getSeconds() : date.getUTCSeconds() + const year = date.getUTCFullYear() + const month = date.getUTCMonth() + 1 + const day = date.getUTCDate() + const hour = date.getUTCHours() + const minute = date.getUTCMinutes() + const second = date.getUTCSeconds() const YYYY = year.toString().padStart(4, '0') const MM = month.toString().padStart(2, '0') @@ -26,5 +26,8 @@ export function formatTimestampParts( const mm = minute.toString().padStart(2, '0') const ss = second.toString().padStart(2, '0') - return { datePart: `${YYYY}-${MM}-${DD}`, timePart: `${hh}:${mm}:${ss}` } + return { + datePart: `${YYYY}-${MM}-${DD}`, + timePart: `${hh}:${mm}:${ss}`, + } } diff --git a/packages/frontend/src/view/components/TimeCell.tsx b/packages/frontend/src/view/components/TimeCell.tsx index f2aa2df36..f54e6c47a 100644 --- a/packages/frontend/src/view/components/TimeCell.tsx +++ b/packages/frontend/src/view/components/TimeCell.tsx @@ -8,7 +8,7 @@ export interface TimeCellProps { } export function TimeCell({ timestamp }: TimeCellProps) { - const { datePart, timePart } = formatTimestampParts(timestamp, 'local') + const { datePart, timePart } = formatTimestampParts(timestamp) return (
diff --git a/packages/frontend/src/view/components/tables/OffersTable.tsx b/packages/frontend/src/view/components/tables/OffersTable.tsx index b37352998..c6a472185 100644 --- a/packages/frontend/src/view/components/tables/OffersTable.tsx +++ b/packages/frontend/src/view/components/tables/OffersTable.tsx @@ -45,7 +45,7 @@ export interface OfferEntry { export function OffersTable(props: OffersTableProps) { const columns: Column[] = [ - { header: 'Time' }, + { header: 'Time (UTC)' }, { header: 'Id' }, { header: 'Trade', align: 'center' }, ...(props.showStatus ? [{ header: 'Status' }] : []), diff --git a/packages/frontend/src/view/components/tables/TransactionsTable.tsx b/packages/frontend/src/view/components/tables/TransactionsTable.tsx index f1fb7ffb8..7ee7e4387 100644 --- a/packages/frontend/src/view/components/tables/TransactionsTable.tsx +++ b/packages/frontend/src/view/components/tables/TransactionsTable.tsx @@ -28,7 +28,7 @@ export interface TransactionEntry { export function TransactionsTable(props: TransactionsTableProps) { const columns: Column[] = [] if (!props.hideTime) { - columns.push({ header: 'Time' }) + columns.push({ header: 'Time (UTC)' }) } columns.push( { header: 'Tx Hash' }, diff --git a/packages/frontend/src/view/old/forced-transactions/ForcedTransactionsTable.tsx b/packages/frontend/src/view/old/forced-transactions/ForcedTransactionsTable.tsx index 1881205f8..8396dad6e 100644 --- a/packages/frontend/src/view/old/forced-transactions/ForcedTransactionsTable.tsx +++ b/packages/frontend/src/view/old/forced-transactions/ForcedTransactionsTable.tsx @@ -21,7 +21,7 @@ export function ForcedTransactionsTable({ noRowsText="no forced transactions have been issued so far" columns={[ { header: 'Type' }, - { header: 'Time' }, + { header: 'Time (UTC)' }, { header: 'Status' }, { header: 'Tx Hash', monospace: true, fullWidth: true }, { header: 'Position' }, diff --git a/packages/frontend/src/view/old/offers/ForcedTradeOffersTable.tsx b/packages/frontend/src/view/old/offers/ForcedTradeOffersTable.tsx index 0b98e732e..f7784b525 100644 --- a/packages/frontend/src/view/old/offers/ForcedTradeOffersTable.tsx +++ b/packages/frontend/src/view/old/offers/ForcedTradeOffersTable.tsx @@ -23,7 +23,7 @@ export function ForcedTradeOffersTable({ columns={[ { header: 'No.' }, { header: 'Type' }, - { header: 'Time' }, + { header: 'Time (UTC)' }, { header: 'Position' }, { header: 'Amount', numeric: true, fullWidth: true }, { header: 'Asset' }, diff --git a/packages/frontend/src/view/old/positions/PositionTransactionsTable.tsx b/packages/frontend/src/view/old/positions/PositionTransactionsTable.tsx index 78449ddbc..47086db18 100644 --- a/packages/frontend/src/view/old/positions/PositionTransactionsTable.tsx +++ b/packages/frontend/src/view/old/positions/PositionTransactionsTable.tsx @@ -42,7 +42,7 @@ export function PositionTransactionsTable( const transactionHistoryTableColumns: Column[] = [ { header: 'Type' }, - { header: 'Time' }, + { header: 'Time (UTC)' }, { header: 'Status' }, { header: 'Tx Hash', monospace: true, fullWidth: true }, { header: 'Amount', numeric: true }, diff --git a/packages/frontend/src/view/old/state-updates/StateUpdateDetails.tsx b/packages/frontend/src/view/old/state-updates/StateUpdateDetails.tsx index 7119b7a4b..baa45cb7a 100644 --- a/packages/frontend/src/view/old/state-updates/StateUpdateDetails.tsx +++ b/packages/frontend/src/view/old/state-updates/StateUpdateDetails.tsx @@ -94,7 +94,7 @@ export function StateUpdateDetails({ noRowsText="this update does not include any forced transactions" columns={[ { header: 'Type' }, - { header: 'Time' }, + { header: 'Time (UTC)' }, { header: 'Tx Hash', monospace: true, fullWidth: true }, { header: 'Amount', numeric: true }, { header: 'Asset' }, diff --git a/packages/frontend/src/view/old/state-updates/StateUpdatesTable.tsx b/packages/frontend/src/view/old/state-updates/StateUpdatesTable.tsx index e2905e9b7..d08cec951 100644 --- a/packages/frontend/src/view/old/state-updates/StateUpdatesTable.tsx +++ b/packages/frontend/src/view/old/state-updates/StateUpdatesTable.tsx @@ -15,7 +15,7 @@ export function StateUpdatesTable({ stateUpdates }: StateUpdatesTableProps) { columns={[ { header: 'No.' }, { header: 'Tx Hash', monospace: true, fullWidth: true }, - { header: 'Time' }, + { header: 'Time (UTC)' }, { header: 'Position updates', numeric: true }, { header: 'Forced txs', numeric: true }, ]} diff --git a/packages/frontend/src/view/pages/home/components/HomeStateUpdatesTable.tsx b/packages/frontend/src/view/pages/home/components/HomeStateUpdatesTable.tsx index 73ccfb7c7..0a6b61b66 100644 --- a/packages/frontend/src/view/pages/home/components/HomeStateUpdatesTable.tsx +++ b/packages/frontend/src/view/pages/home/components/HomeStateUpdatesTable.tsx @@ -23,7 +23,7 @@ export function HomeStateUpdatesTable(props: HomeStateUpdatesTableProps) { return ( - {formatTimestamp(props.ethereumTimestamp, 'utc')} UTC + {formatTimestamp(props.ethereumTimestamp)} UTC {/* Disabled until StarkEx timestamp will be fixed diff --git a/packages/frontend/src/view/pages/transaction/components/HistoryTable.tsx b/packages/frontend/src/view/pages/transaction/components/HistoryTable.tsx index a365dbae2..8ad3a91bf 100644 --- a/packages/frontend/src/view/pages/transaction/components/HistoryTable.tsx +++ b/packages/frontend/src/view/pages/transaction/components/HistoryTable.tsx @@ -23,7 +23,7 @@ export function TransactionHistoryTable(props: TransactionHistoryTableProps) {
- {formatTimestamp(props.timestamp.timestamp, 'utc')} UTC{' '} + {formatTimestamp(props.timestamp.timestamp)} UTC{' '} ({delayDays} {delayDays === 1 ? 'day' : 'days'}) diff --git a/packages/frontend/src/view/pages/user/components/UserBalanceChangesTable.tsx b/packages/frontend/src/view/pages/user/components/UserBalanceChangesTable.tsx index 7b765da06..4f43683ae 100644 --- a/packages/frontend/src/view/pages/user/components/UserBalanceChangesTable.tsx +++ b/packages/frontend/src/view/pages/user/components/UserBalanceChangesTable.tsx @@ -28,7 +28,7 @@ export function UserBalanceChangesTable(props: UserBalanceChangesTableProps) { return (