From fe2a8eeea27a5b9b92cfcd17f3dddef745b9e1a1 Mon Sep 17 00:00:00 2001 From: Jannik Streek Date: Wed, 18 Dec 2024 08:59:13 +0100 Subject: [PATCH] remove relative time utils --- assets/js/app.js | 3 +-- assets/js/timeUtils.js | 13 ------------- 2 files changed, 1 insertion(+), 15 deletions(-) delete mode 100644 assets/js/timeUtils.js diff --git a/assets/js/app.js b/assets/js/app.js index d65c9b97..f5b54c2d 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -1,7 +1,6 @@ import { Modal, Tooltip } from "bootstrap" import Sortable from 'sortablejs'; -import { setIdeaLabelBackgroundColor } from "./label" -import { getRelativeTimeString } from "./timeUtils" +import { setIdeaLabelBackgroundColor } from "./label"; // activate all tooltips: const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]'); [...tooltipTriggerList].map(tooltipTriggerEl => new Tooltip(tooltipTriggerEl)); diff --git a/assets/js/timeUtils.js b/assets/js/timeUtils.js deleted file mode 100644 index ef832029..00000000 --- a/assets/js/timeUtils.js +++ /dev/null @@ -1,13 +0,0 @@ -export const getRelativeTimeString = (date, language = 'en') => { - console.log(language) - const rtf = new Intl.RelativeTimeFormat(language, { numeric: 'auto' }); - const now = new Date(); - const diffInMs = date - now; - const diffInDays = Math.round(diffInMs / (1000 * 60 * 60 * 24)); - const diffInHours = Math.round(diffInMs / (1000 * 60 * 60)); - const diffInMinutes = Math.round(diffInMs / (1000 * 60)); - - if (Math.abs(diffInMinutes) < 60) return rtf.format(diffInMinutes, 'minute'); - if (Math.abs(diffInHours) < 24) return rtf.format(diffInHours, 'hour'); - return rtf.format(diffInDays, 'day'); -}; \ No newline at end of file