npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

brazilianholiday

v2.0.5

Published

Biblioteca para consulta de feriados brasileiros.

Downloads

152

Readme

Brazilian Holiday

Simples biblioteca para verificação de feriado a partir de data recebida.

Instalação

npm install brazilianholiday

Métodos

isHoliday(date, uf = null)

Verifica se data é um feriado

//PARAMS

date
- required: true
- type: string
- format: 'DD/MM/YYYY'

uf
- required: false
- type: string
- format: 'XX'
const {brazilianHoliday} = require('brazilianholiday');

let date = '01/01/2023';

console.log(brazilianHoliday.isHoliday(date));

/*
{
  holiday: true,
  description: 'Confraternização Universal',
  date: '01/01/2023'
}
*/

date = '20/01/2023';

console.log(brazilianHoliday.isHoliday(date, 'AC'));

/*
{ 
    holiday: true, 
    description: 'Dia do Católico', 
    date: '20/01/2023' 
}
*/

createHoliday([objects])

Possibilita a criação de feriados locais/municipais.

  • Os feriados não são armazenados em bancos e cada requisição implica no reset daqueles já criados.

  • Quando existir a necessidade de novos feriados, a requisição createHoliday deve anteceder a consulta do método isHoliday;

  • Desde a versão 2.0.1 (versão em que a função foi disponibilizada), os feriados criados não consideram o estado e a cidade para verificação feita pelo método isHoliday, sendo apenas parâmetros obrigatórios de controle.

  • O método retorna um array de objetos que faz referência aos feriados criados.

//PARAMS

date
- required: true
- type: string
- format: 'DD/MM/YYYY'

uf
- required: true
- type: string
- format: 'XX'

city
- required: true
- type: string
- format: 'XXXXXX'

description
- required: true
- type: string
- format: 'XXXXXX'

uf
- required: true
- type: string
- format: 'XX'

moveable
- required: false
- type: boolean
- format: true || false
const {brazilianHoliday} = require('brazilianholiday');

brazilianHoliday.createHoliday([
    {
        date: '15/05/2023', 
        city: 'Passos', 
        uf: 'MG', 
        description: 'Aniversário de Passos', 
        moveable: false
    },
    {
        date: '06/08/2023', 
        city: 'Passos', 
        uf: 'MG', 
        description: 'Dia de Bom Jesus dos Passos', 
        moveable: false
    }
]);

console.log(brazilianHoliday.isHoliday('15/05/2023'))
/*
{
  holiday: true,
  description: 'Aniversário de Passos',
  date: '15/05/2023'
}
*/

all()

Retorna json completo de feriados.

const {brazilianHoliday} = require('brazilianholiday');

console.log(brazilianHoliday.all());
/*
{
  moveable: [ Array ],
  national: [ Array ],
  state: [ Array ],
  createdHolidays: [ Array ]
}
*/

Histórico de Versões

  • 2.0.5 [STABLE]
    • DOC: readme file
  • 2.0.4 [STABLE]
    • FIX: tests
  • 2.0.3 [STABLE]
    • DOC: license file
  • 2.0.2 [STABLE]
    • FIX: readme documentation
  • 2.0.1 [STABLE]
    • FEAT: function createHoliday
  • 1.0.9 [STABLE]
    • FEAT: function all and test
  • 1.0.8 [STABLE]
    • FEAT: function isHoliday

Como Contribuir

Ajude-nos alimentando o arquivo .json com feriados móveis que variam a cada ano.

"moveable": [
        {
            "year": "2024",
            "holidays": [
                {
                    "date": "12/02",
                    "description": "Carnaval"
                },
                {
                    "date": "13/02",
                    "description": "Carnaval"
                },
                {
                    "date": "29/03",
                    "description": "Paixão de Cristo"
                }
            ]
        }
    ]

Licença:

MIT © Otávio Silva 2023

Linkedin Badge