fix: Timestamps being broken

Don't even know how this happened, I think my computer was just having a
stroke of some sort when I was initally doing this.
This commit is contained in:
April Hall 2025-02-25 02:35:01 -05:00
parent c5b1d76954
commit a33437cac6
No known key found for this signature in database
GPG Key ID: A49AC35CB186266C
7 changed files with 8 additions and 20 deletions

View File

@ -28,7 +28,7 @@ io.on('connection', async (socket) => {
message: msg.content,
imageSrc: sender.image,
channel: msg.channel,
timestamp: timestamp.getTime(),
timestamp: timestamp,
});
}
});

View File

@ -16,7 +16,7 @@
<span class="font-bold">{user}</span>
<span>·</span>
<span class="text-muted-foreground"
>{new Date(timestamp).toLocaleDateString('en-US', {
>{timestamp.toLocaleDateString('en-US', {
year: 'numeric',
month: 'short',
day: 'numeric',

View File

@ -29,12 +29,13 @@ class Websocket {
// Add message to local messages array
private loadMessage(newMsg: TypeMessage) {
console.log(newMsg.timestamp);
this.messages = [
{
message: newMsg.message,
imageSrc: newMsg.imageSrc,
user: newMsg.user,
timestamp: newMsg.timestamp,
timestamp: new Date(newMsg.timestamp),
},
...this.messages,
];

View File

@ -36,7 +36,7 @@ export function startupSocketIOServer(httpServer: HttpServer | null) {
message: msg.content,
imageSrc: sender.image,
channel: msg.channel,
timestamp: timestamp.getTime(),
timestamp: timestamp,
});
}
});

View File

@ -6,12 +6,6 @@ interface Messages {
error: Error | null;
}
interface CassandraTimestamp {
low: number;
high: number;
unsigned: boolean;
}
function createDelay(ms: number) {
return new Promise((res) => setTimeout(res, ms));
}
@ -135,13 +129,6 @@ class Db {
};
}
}
// Timestamp to Epoch method
tsEpoch(ts: CassandraTimestamp) {
const low = ts.low >>> 0;
const high = ts.high >>> 0;
return high * 2 ** 32 + low;
}
}
const db = new Db();

View File

@ -2,7 +2,7 @@ export interface TypeMessage {
message: string;
imageSrc: string;
user: string;
timestamp: number;
timestamp: Date;
}
export interface TypeFullMessage {
@ -10,5 +10,5 @@ export interface TypeFullMessage {
message: string;
imageSrc: string;
user: string;
timestamp: number;
timestamp: Date;
}

View File

@ -31,7 +31,7 @@ export async function load({ params, request }): Promise<ChannelLoad> {
user: sender.username,
imageSrc: sender.image,
channel: value.channel,
timestamp: db.tsEpoch(value.timestamp),
timestamp: new Date(value.timestamp),
};
})
: [];