Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created April 16, 2022 00:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/7f726f809f9c4864ffa557527f2ebea1 to your computer and use it in GitHub Desktop.
Save parzibyte/7f726f809f9c4864ffa557527f2ebea1 to your computer and use it in GitHub Desktop.
// https://parzibyte.me/blog
const inicio = new Date("2021-01-01T00:00:00");
const fin = new Date("2022-04-10T00:00:00");
const UN_DIA_EN_MILISEGUNDOS = 1000 * 60 * 60 * 24;
const INTERVALO_COOPERACION = UN_DIA_EN_MILISEGUNDOS * 7; // Cada semana
const COOPERACION = 500;
const formateadorFecha = new Intl.DateTimeFormat('es-MX', { dateStyle: 'medium', });
const formateadorDinero = new Intl.NumberFormat("en", { style: "currency", "currency": "MXN" });
let suma = 0;
for (let i = inicio; i <= fin; i = new Date(i.getTime() + INTERVALO_COOPERACION)) {
suma += COOPERACION;
console.log(`Para ${formateadorFecha.format(i)} se lleva ${formateadorDinero.format(suma)}`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment