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 42 43 44 45 46 47 48 49 | 1x 1x 1x 1x 1x 86x 86x 80x 1x 79x 79x 79x 79x 30x 79x 876x 718x 15x 876x 158x 3x 79x 7x | import { setFormatoFecha } from "./formatearfecha";
import { CodigoFormatoFecha, FormatoFeriados, ErroresComunes } from "../constants";
import { disgregarFecha } from "./disgregarfecha";
import { validarFecha } from "./validarfecha";
/**
*
* @param fecha
* @param feriados
* Valida que una fecha sea hábil o no dados la fecha y el listado de feriados de su país. Valida feriados considerando dd mm yyyy y fines de semana.
*/
export function isHabil ( fecha: string, listaFeriados: FormatoFeriados[] ): boolean {
try {
validarFecha(fecha);
if (listaFeriados.length === 0) {
throw new Error(ErroresComunes.ERR_FERIADOS_VACIO)
}
let habil = true;
let dateFormatted = setFormatoFecha( fecha, CodigoFormatoFecha.FMT_INVERSO );
const diaObtenido = new Date(dateFormatted).getDay();
/* Fin de semana */
if (diaObtenido === 0 || diaObtenido === 6){
habil = false;
}
const { dia, mes, anio } = disgregarFecha(dateFormatted);
listaFeriados.filter(filtro => !filtro.hasOwnProperty("anio")).map(fecha =>{
if (fecha.dia === dia && fecha.mes === mes){
habil = false;
}
});
listaFeriados.filter(filtro => filtro.hasOwnProperty("anio")).map(fecha =>{
if (fecha.dia === dia && fecha.mes === mes && fecha.anio === anio){
habil = false;
}
});
return habil;
} catch (error) { throw (error) }
} |