@nolock/ezdate is a date module designed for brazilian, it validates business days based on national holidays.
$ npm install @nolock/ezdate --save
# or with yarn
$ yarn add @nolock/ezdate
Our current server location is "America/Sao_Paulo"
isBusinessDay(date: string | Date, hour: number, minute: number)
date
Opcional, default: new Date()
hour
Opcional, default: 17
minute
Opcional, default: 0
Example Date = '2021-07-19 16:30:00'
import {isBusinessDay} from '@nolock/ezdate'
console.log(isBusinessDay());
//true
console.log(isBusinessDay('2021-12-25'));
//false
console.log(isBusinessDay(new Date(), 19, 30));
//true
console.log(isBusinessDay(new Date(), 15, 30));
//false
getBusinessDay(date: string | Date)
date
Opcional, default: new Date()
import {getBusinessDay} from '@nolock/ezdate'
console.log(getBusinessDay());
//2021-07-19T03:00:00.000Z
console.log(getBusinessDay('2021-12-25'));
//2021-12-27T03:00:00.000Z
getNextBusinessDay(date: string | Date, days: number)
date
Opcional, default: new Date()
days
Opcional, default: 1
import {getNextBusinessDay} from '@nolock/ezdate'
console.log(getNextBusinessDay());
//2021-07-20T03:00:00.000Z
console.log(getNextBusinessDay(new Date(), 3));
//2021-07-22T03:00:00.000Z
console.log(getNextBusinessDay(new Date(), 5));
//2021-07-26T03:00:00.000Z
getDate(date: string | Date)
date
Required
import {getDate} from '@nolock/ezdate'
console.log(getDate('2021-07-19'));
//2021-07-19T03:00:00.000Z
getYear(date: string | Date)
date
Opcional, default: new Date()
import {getYear} from '@nolock/ezdate'
console.log(getYear('2021-07-19'));
//2021
formatDate(date: string | Date, type: TypeDate)
date
Required
type
Required
enum TypeDate {
BR,
DB
}
import {formatDate, TypeDate} from '@nolock/ezdate'
console.log(formatDate('2021-07-19', TypeDate.BR));
//19/07/2021
console.log(formatDate('2021-07-19', 'BR'));
//19/07/2021
getNationalHolidays(year: number)
year
Optional, default: current year
import {getNationalHolidays} from '@nolock/ezdate'
console.log(getNationalHolidays(2021);
// [
// { date: '2021-01-01', description: 'Ano Novo' },
// { date: '2021-02-16', description: 'Carnaval' },
// { date: '2021-04-02', description: 'Sexta-feira Santa' },
// { date: '2021-04-04', description: 'Páscoa' },
// { date: '2021-04-21', description: 'Tiradentes' },
// { date: '2021-05-01', description: 'Dia do Trabalho' },
// { date: '2021-06-03', description: 'Corpus Christi' },
// { date: '2021-09-07', description: 'Independência do Brasil' },
// { date: '2021-10-12', description: 'Nossa Senhora Aparecida' },
// { date: '2021-11-02', description: 'Dia de Finados' },
// { date: '2021-11-15', description: 'Proclamação da República' },
// { date: '2021-12-25', description: 'Natal' }
// ]
isHoliday(date: string | Date)
Example Date = '2021-07-19'
date
Optional, default: new Date()
import {isHoliday} from '@nolock/ezdate'
console.log(isHoliday());
//false
console.log(isHoliday('2021-01-01'));
//true
@nolock/ezdate is MIT licensed.