fix timestamps on frontend

This commit is contained in:
jejolare 2024-09-26 18:32:23 +07:00
parent a3dbf07b69
commit e1662effa6
4 changed files with 8 additions and 4 deletions

View file

@ -88,6 +88,8 @@ function LatestBlocks({ fetchedInfo, fetchedLatestBlocks }: { fetchedInfo: Info
const tableHeaders = [ "HEIGHT", "TIMESTAMP (UTC)", "AGE", "SIZE", "TRANSACTIONS", "HASH" ];
const tableElements = blocks.map(e => {
console.log(e);
const hash = e.hash;
const hashLink = hash ? "/block/" + hash : "/";
return [

View file

@ -1,7 +1,7 @@
interface BlockInfo {
type: "PoS" | "PoW";
timestamp?: Date;
actualTimestamp?: BigInt;
timestamp?: string;
actualTimestamp?: string;
difficulty: string;
minerTextInfo?: string;
cummulativeDiffAdjusted?: string;

View file

@ -154,7 +154,7 @@ function Block(props: BlockProps) {
</tr>
<tr>
<td>Timestamp (UTC):</td>
<td>{blockInfo?.timestamp ? Utils.formatTimestampUTC(+new Date(blockInfo?.timestamp)) : "-"}</td>
<td>{blockInfo?.timestamp ? Utils.formatTimestampUTC(+new Date(parseInt(blockInfo?.timestamp, 10))) : "-"}</td>
</tr>
<tr>
<td>ID</td>

View file

@ -81,10 +81,12 @@ class Utils {
static transformToBlocks(result: any, reverse: boolean = false, hashField: boolean = false): Block[] {
if (result.sucess === false) return [];
if (!(result instanceof Array)) return [];
console.log(result);
return (reverse ? result.reverse() : result).map((e: any) => ({
height: e.height,
type: e.type === '0' ? "PoS" : "PoW",
timestamp: +new Date(e.timestamp),
timestamp: +new Date(parseInt(e.timestamp, 10)),
size: e.total_txs_size,
transactions: e.tr_count,
hash: !hashField ? e.tx_id : e.hash