Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
colombian-holidays
Advanced tools
Readme
TypeScript module to calculate colombian holidays for any given year.
To install as a dependency of your project:
npm install colombian-holidays
The default export is a function to get all the holidays for a given year.
The year
should be between 1583 and 4099 (see Pascua package).
const colombianHolidays = require("colombian-holidays").default;
import colombianHolidays from "colombian-holidays";
You get a function that you can use to get the complete list of holidays for a given year:
const colombianHolidays2015 = colombianHolidays({ year: 2015 });
The content of the colombianHolidays2015
variable will be the following array:
[
{
date: "2015-01-01",
celebrationDate: "2015-01-01",
name: {
es: "Año Nuevo",
en: "New Year's day",
},
nextMonday: false,
},
{
date: "2015-01-06",
celebrationDate: "2015-01-12",
name: {
es: "Reyes Magos",
en: "Epiphany",
},
nextMonday: true,
},
{
date: "2015-03-19",
celebrationDate: "2015-03-23",
name: {
es: "San José",
en: "Saint Joseph's Day",
},
nextMonday: true,
},
{
date: "2015-04-02",
celebrationDate: "2015-04-02",
{ es: "Jueves Santo", en: "Maundy Thursday" },
nextMonday: false,
},
{
date: "2015-04-03",
celebrationDate: "2015-04-03",
{ es: "Viernes Santo", en: "Good Friday" },
nextMonday: false,
},
{
date: "2015-05-01",
celebrationDate: "2015-05-01",
name: {
es: "Día del Trabajo",
en: "Labour Day",
}
nextMonday: false,
},
{
date: "2015-05-14",
celebrationDate: "2015-05-18",
name: { es: "Ascensión del Señor", en: "Ascension of Jesus" },
nextMonday: true,
},
{
date: "2015-06-04",
celebrationDate: "2015-06-08",
name: { es: "Corpus Christi", en: "Corpus Christi" },
nextMonday: true,
},
{
date: "2015-06-12",
celebrationDate: "2015-06-15",
name: { es: "Sagrado Corazón de Jesús", en: "Sacred Heart" },
nextMonday: true,
},
{
date: "2015-06-29",
celebrationDate: "2015-06-29",
name: {
es: "San Pedro y San Pablo",
en: "Saint Peter and Saint Paul",
},
nextMonday: true,
},
{
date: "2015-07-20",
celebrationDate: "2015-07-20",
name: {
es: "Grito de la Independencia",
en: "Declaration of Independence",
},
nextMonday: false,
},
{
date: "2015-08-07",
celebrationDate: "2015-08-07",
name: {
es: "Batalla de Boyacá",
en: "Battle of Boyacá",
},
nextMonday: false,
},
{
date: "2015-08-15",
celebrationDate: "2015-08-17",
name: {
es: "Asunción de la Virgen",
en: "Assumption of Mary",
},
nextMonday: true,
},
{
date: "2015-10-12",
celebrationDate: "2015-10-12",
name: {
es: "Día de la Raza",
en: "Columbus Day",
},
nextMonday: true,
},
{
date: "2015-11-01",
celebrationDate: "2015-11-02",
name: {
es: "Todos los Santos",
en: "All Saints’ Day",
},
nextMonday: true,
},
{
date: "2015-11-11",
celebrationDate: "2015-11-16",
name: { es: "Independencia de Cartagena", en: "Independence of Cartagena" },
nextMonday: true,
},
{
date: "2015-12-08",
celebrationDate: "2015-12-08",
name: { es: "Inmaculada Concepción", en: "Immaculate Conception" },
nextMonday: false,
},
{
date: "2015-12-25",
celebrationDate: "2015-12-25",
name: { es: "Navidad", en: "Christmas" },
nextMonday: false,
},
];
Optionally, you can request the holidays for just a given month:
const colombianHolidays2015 = colombianHolidays({
year: 2015,
month: 1 /* January */,
});
Returns:
[
{
date: "2015-01-01",
celebrationDate: "2015-01-01",
name: {
es: "Año Nuevo",
en: "New Year's day",
},
nextMonday: false,
},
{
date: "2015-01-06",
celebrationDate: "2015-01-12",
name: {
es: "Reyes Magos",
en: "Epiphany",
},
nextMonday: true,
},
];
You can opt-in to have the function return native JavaScript dates instead of strings for the date
and celebrationDate
properties by using the valueAsDate
option:
const colombianHolidays2015 = colombianHolidays({
year: 2015,
valueAsDate: true,
});
If the year is omitted, by default the function will return the holidays for the current year:
const currentYearHolidaysAsStrings = colombianHolidays();
const currentYearHolidaysAsDates = colombianHolidays({ valueAsDate: true });
The package provides two helper functions which can be imported from lib/utils
:
Returns true
if the given date is a colombian holiday, otherwise returns false
.
import { isHoliday } from "colombian-holidays/lib/utils/isHoliday";
const date = new Date("2018-01-01");
if (isHoliday(date)) {
console.log("it is a colombian holiday");
} else {
console.log("it is NOT a colombian holiday");
}
Similar to isHoliday
but will return the corresponding holiday for a given date or null
if there is no matching holiday.
import { getHoliday } from "colombian-holidays/lib/utils/getHoliday";
const date = new Date("2018-01-01");
const newYear = getHoliday(date);
/*
{
celebrationDate: "2018-01-01",
date: "2018-01-01",
name: { en: "New Year's Day", es: "Año Nuevo" },
nextMonday: false,
}
*/
To get the values as date use the options argument:
const newYearAsDate = getHoliday(date, { valueAsDate: true });
Returns an array with the colombian holidays within two dates:
import { holidaysWithinInterval } from "colombian-holidays/lib/utils/holidaysWithinInterval";
const start = new Date("2021-01-01");
const end = new Date("2021-01-11");
const holidays = holidaysWithinInterval({ start, end });
// const holidays = holidaysWithinInterval({ start, end, valueAsDate: true });
returns:
[
{
celebrationDate: "2021-01-01",
date: "2021-01-01",
name: {
es: "Año Nuevo",
en: "New Year's day",
},
nextMonday: false,
},
{
celebrationDate: "2021-01-11",
date: "2021-01-06",
name: {
es: "Reyes Magos",
en: "Epiphany",
},
nextMonday: true,
},
];
The module is written in TypeScript and type definitions files are included.
FAQs
Colombian holidays
The npm package colombian-holidays receives a total of 188 weekly downloads. As such, colombian-holidays popularity was classified as not popular.
We found that colombian-holidays demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.