use more generic function for time conversions

This commit is contained in:
MathMan05 2024-09-03 11:17:06 -05:00
parent 0fc51f0e71
commit 4c4f7f8619
4 changed files with 10 additions and 8 deletions

View file

@ -910,15 +910,15 @@ class Channel extends SnowFlake{
private findClosest(id:string|undefined){
if(!this.lastmessageid||!id)return;
let flake:string|undefined=this.lastmessageid;
const time=Number((BigInt(id)>>22n)+1420070400000n);
let flaketime=Number((BigInt(flake)>>22n)+1420070400000n);
const time=SnowFlake.stringToUnixTime(id);
let flaketime=SnowFlake.stringToUnixTime(flake);
while(flake&&time<flaketime){
flake=this.idToPrev.get(flake);
if(!flake){
return;
}
flaketime=Number((BigInt(flake)>>22n)+1420070400000n);
flaketime=SnowFlake.stringToUnixTime(flake);
}
return flake;
}