Skip to content

Commit

Permalink
Update time.js
Browse files Browse the repository at this point in the history
Signed-off-by: Grouvex <168425996+Grouvex@users.noreply.github.com>
  • Loading branch information
Grouvex authored Feb 26, 2025
1 parent e310515 commit 835c5d9
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions time.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
function actualizarFechas(uT, elementoId) {
try {
const elemento = document.getElementById(elementoId);
const f = new Date(uT * 1000).toUTCString();
if (uT >= Math.floor(Date.now() / 1000)) {
const fUT = Math.floor(Date.now() / 1000);
const diferencia = uT - fUT;
const seg = diferencia % 60;const min = Math.floor((diferencia / 60) % 60);const h = Math.floor((diferencia / 3600) % 24);const d = Math.floor(diferencia / 86400);const m = Math.floor(d / 30.24);const a = Math.floor(d / 365.44);
const f1 = `(${a} year(s), ${m} month(s), ${d}d, ${h}h, ${min}m y ${seg}s left)`;
elemento.textContent = `${f} ¦ ${f1}`;
} else {
elemento.textContent = f;
}
} catch (error) {
console.error('Error al actualizar las fechas:', error);
}
try {const elemento = document.getElementById(elementoId);if (!elemento) {throw new Error(`Elemento con ID ${elementoId} no encontrado.`);}
const fechaActual = Math.floor(Date.now() / 1000); // Timestamp actual en segundos
const fechaUT = new Date(uT * 1000).toUTCString(); // Convertir uT a fecha legible
if (uT >= fechaActual) {const diferencia = uT - fechaActual;const seg = diferencia % 60;const min = Math.floor((diferencia / 60) % 60);const h = Math.floor((diferencia / 3600) % 24);const d = Math.floor(diferencia / 86400);const m = Math.floor(d / 30.44);const a = Math.floor(d / 365.25);const tiempoRestante = `(${a} año(s), ${m} mes(es), ${d}d, ${h}h, ${min}m y ${seg}s restantes)`;elemento.textContent = `${fechaUT} ¦ ${tiempoRestante}`;
} else {elemento.textContent = fechaUT;}
} catch (error) {console.error('Error al actualizar las fechas:', error);}
}

0 comments on commit 835c5d9

Please sign in to comment.