Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

brazilianholiday

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

brazilianholiday - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

2

package.json
{
"name": "brazilianholiday",
"version": "1.0.3",
"version": "1.0.4",
"description": "Biblioteca para feriados brasileiros no âmbito nacional e estadual",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -13,3 +13,3 @@ # Brazilian Holiday

### isNational()
### isNational(date)
> Verifica se data é um feriado nacional.

@@ -30,6 +30,22 @@

*/
~~~
### isState(date, uf)
> Verifica se data é um feriado estadual
~~~javascript
const {brazilianHoliday} = require('brazilianholiday');
let date = '21/04/2023';
console.log(brazilianHolidays.isState(date, 'MG'));
/*
{
holiday: true,
date: '21/04/2023',
description: 'Data Magna de Minas Gerais'
}
*/
~~~
## Histórico de Versões

@@ -39,2 +55,4 @@

* FEAT: function isNational
* 1.0.4
* FEAT: function isState

@@ -41,0 +59,0 @@ ## Contribuidor:

@@ -35,3 +35,3 @@ {

"uf": "AC",
"hollidays": [
"holidays": [
{

@@ -61,3 +61,3 @@ "date": "20/01",

"uf": "AL",
"hollidays": [
"holidays": [
{

@@ -64,0 +64,0 @@ "date": "24/06",

const {national, state} = require('./holidays.json')
function formatDate(date){
let splitDate = date.split('/');
let dateFormated = new Date(date);
let dateFormated = new Date(`${splitDate[2]}-${splitDate[1]}-${splitDate[0]}T03:00:00`);
let dayNumber = dateFormated.getDate();
let monthNumber = dateFormated.getMonth()+1;
let monthNumber = dateFormated.getMonth() + 1;

@@ -26,6 +28,23 @@ let day = dayNumber < 10 ? `0${dayNumber}` : dayNumber;

function isState(date, uf){
let ufFinded = state.find(element=> element.uf == uf);
let holiday = null;
if (ufFinded && ufFinded.holidays.length > 0){
holiday = ufFinded.holidays.find(element => element.date == formatDate(date));
}
return {
holiday: holiday ? true : false,
date,
description: holiday ? holiday.description : false
}
}
module.exports = {
brazilianHoliday: {
isNational
isNational,
isState
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc