From 95c6acfe62c477324eb82fe035c21ae5c3ad4e89 Mon Sep 17 00:00:00 2001 From: Ethan Davidson <31261035+EthanThatOneKid@users.noreply.github.com> Date: Sun, 1 Oct 2023 14:24:29 -0700 Subject: [PATCH] fix Discord timestamp calculation Incorrect output: ``` Created commit [update `/example` shortlink](https://acmcsuf.com/code/commit/0333b548246fbddd8c309637f06fd31b14d6f805)! This shortlink will be expire in . ``` --- main.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/main.ts b/main.ts index f37004a..dd2ed41 100644 --- a/main.ts +++ b/main.ts @@ -135,9 +135,11 @@ export function makeHandler(kv: Deno.Kv) { if (ttlDuration) { // Render to Discord timestamp format. // https://gist.github.com/LeviSnoot/d9147767abeef2f770e9ddcd91eb85aa - const discordTimestamp = ``; + const discordTimestamp = toDiscordTimestamp( + (Date.now() + ttlDuration.raw) * 0.001, + ); content += - `\n\nThis shortlink will be expire in ${discordTimestamp}.`; + `\n\nThis shortlink will be expire ${discordTimestamp}.`; } // Send the success message. @@ -229,3 +231,7 @@ export function makeShorterOptions( }, }; } + +function toDiscordTimestamp(timestamp: number) { + return ``; +}