Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | 1x 1x 1x 1x 1x 1x 93x 93x 89x 89x 89x 89x 89x 89x 55x 10x 5x 8x 11x 4x | import { CodigoFormatoFecha } from "../constants";
import { validarFecha } from "./validarfecha";
import { setFormatoFecha } from "./formatearfecha";
import { getFormatoFecha } from "./getformatofecha";
import { disgregarFecha } from "./disgregarfecha";
/**
* @param fecha
* @param nDias
* Obtiene una nueva fecha al sumar o restar días
*/
export function addDias ( fecha: string, nDias: number ): string {
try {
validarFecha(fecha);
const aFecha = new Date(setFormatoFecha(fecha, CodigoFormatoFecha.FMT_INVERSO));
const newDate = new Date(aFecha.setDate(aFecha.getDate() + nDias));
const newDateString = newDate.toISOString().slice(0,10).replace(/[-]/g, '/');
const {dia, mes, anio} = disgregarFecha(newDateString);
const fmto = getFormatoFecha(fecha);
switch (fmto)
{
case CodigoFormatoFecha.FMT_ESPANOL:
return dia + '/' + mes + '/' + anio;
case CodigoFormatoFecha.FMT_ITALIANO:
return dia + '-' + mes + '-' + anio;
case CodigoFormatoFecha.FMT_PLANO:
return dia + mes + anio;
case CodigoFormatoFecha.FMT_INVERSOPLANO:
return anio + mes + dia;
case CodigoFormatoFecha.FMT_INVERSO:
return anio + '/' + mes + '/' + dia;
}
} catch (error) {
throw (error)
}
} |