Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update timestamps #217

Merged
merged 2 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/components/Tables/PurchaseHistoryTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import {
TableHead,
TablePagination,
TableRow,
Tooltip,
} from '@mui/material';
import TimeAgo from 'javascript-time-ago';
import en from 'javascript-time-ago/locale/en';
import { useState } from 'react';

import { getBalanceString } from '@/utils/functions';
import { getBalanceString, getTimeStringLong } from '@/utils/functions';

import { Address, Link } from '@/components/Elements';

Expand Down Expand Up @@ -114,7 +115,14 @@ export const PurchaseHistoryTable = ({ data }: PurchaseHistoryTableProps) => {
</StyledTableCell>
<StyledTableCell align='center'>{type}</StyledTableCell>
<StyledTableCell align='center'>
{timeAgo.format(timestamp, 'round-minute')}
<Tooltip title={getTimeStringLong(timestamp)}>
<p>
{timeAgo.format(timestamp, {
steps: [{ formatAs: 'day' }],
labels: 'long',
})}
</p>
</Tooltip>
</StyledTableCell>
</StyledTableRow>
)
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/sale/purchaseHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ export const usePurchaseHistory = (
address: account,
core,
extrinsicId: `${height}-${extrinsicId}`,
timestamp: new Date(`${timestamp}Z`),
timestamp: new Date(Number(timestamp)),
price: parseInt(price),
type: purchaseType,
}) as PurchaseHistoryItem
} as PurchaseHistoryItem)
)
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/sale/saleDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ export const useSaleDetails = (network: NetworkType, saleCycle: number) => {
address: account,
core,
extrinsicId: `${height}-${extrinsicId}`,
timestamp: new Date(`${timestamp}Z`),
timestamp: new Date(Number(timestamp)),
price: parseInt(price),
type: purchaseType,
}) as PurchaseHistoryItem
} as PurchaseHistoryItem)
)
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/sale/salesHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ export const useSalesHistory = (network: NetworkType) => {
regionEnd,
startBlock: height,
endBlock: saleEnd,
startTimestamp: Date.parse(`${timestamp}Z`),
endTimestamp: Date.parse(`${tsSaleEnd}Z`),
startTimestamp: Number(timestamp),
endTimestamp: Number(tsSaleEnd),
startPrice,
endPrice,
}) as SalesHistoryItem
} as SalesHistoryItem)
)
);
}
Expand Down
8 changes: 6 additions & 2 deletions src/utils/functions/formatting.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import moment from 'moment';

export const getTimeStringShort = (timestamp: number): string => {
export const getTimeStringShort = (timestamp: number | Date): string => {
return moment(timestamp).format('MMM DD HH:mm');
};

export const getTimeStringLong = (timestamp: number): string => {
export const getTimeStringLong = (timestamp: number | Date): string => {
return moment(timestamp).format('MMM DD YYYY HH:mm');
};

export const getUTCTimeString = (timestamp: number | Date): string => {
return moment.utc(timestamp).format('MMM DD YYYY HH:mm:ss (+UTC)');
};
Comment on lines +11 to +13
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already merged this, but why did you add this if it is not used?

Loading