brazilianholiday
Advanced tools
Comparing version 1.0.3 to 1.0.4
{ | ||
"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 | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11387
349
60