don't try to fix the seconds difference
All checks were successful
PR Check / lint-and-format (pull_request) Successful in 23s

This commit is contained in:
Mylloon 2024-10-13 11:36:07 +02:00
parent 58f3a42126
commit bb2337cea0
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 1 additions and 9 deletions

View file

@ -111,14 +111,6 @@ describe("Relative time", () => {
expect(timeDeltaToString(name)).toMatch(/1w 1d 6h|1w 1d 5h 59m 5\ds/); expect(timeDeltaToString(name)).toMatch(/1w 1d 6h|1w 1d 5h 59m 5\ds/);
}); });
} }
{
// We do +2 because we do -2 in the code to compensate for Discord's latency.
// This gives us the case where (normally) there is a 0s delay.
const name = Date.now() + 2 * 1000;
test(name.toString(), () => {
expect(timeDeltaToString(name)).toMatch(/\ds/);
});
}
{ {
const name = Date.now(); const name = Date.now();
test(name.toString(), () => { test(name.toString(), () => {

View file

@ -101,7 +101,7 @@ export const strToSeconds = (time: string) => {
*/ */
export const timeDeltaToString = (time: number) => { export const timeDeltaToString = (time: number) => {
const now = Date.now(); const now = Date.now();
let secondsDifference = Math.abs(Math.ceil((time - now) / 1000) - 2); let secondsDifference = Math.abs(Math.ceil((time - now) / 1000));
if (secondsDifference === 0) { if (secondsDifference === 0) {
return "0s"; return "0s";