add many fonction & add &me command

This commit is contained in:
arthur
2024-06-25 13:45:14 +02:00
parent 77673accb1
commit f0aa3a71fa
6 changed files with 240 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
module.exports = function formatDate(timestamp) {
const currentDate = new Date();
const targetDate = new Date(timestamp);
const diffTime = Math.abs(targetDate - currentDate);
const diffDays = Math.floor(diffTime / (1000 * 60 * 60 * 24));
const diffHours = Math.floor((diffTime % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const diffMinutes = Math.floor((diffTime % (1000 * 60 * 60)) / (1000 * 60));
let result = "";
if (diffDays > 0) {
result += `${diffDays} jour${diffDays > 1 ? "s" : ""}, `;
}
if (diffHours > 0) {
result += `${diffHours} heure${diffHours > 1 ? "s" : ""} et `;
}
result += `${diffMinutes} minute${diffMinutes > 1 ? "s" : ""}`;
return result;
};