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

@nolock/ezdate

v1.1.1

Published

@nolock/ezdate is a date module designed for brazilian, it validates business days based on national holidays.

Downloads

566

Readme

Description

@nolock/ezdate is a date module designed for brazilian, it validates business days based on national holidays.

Installation

$ npm install @nolock/ezdate --save

# or with yarn

$ yarn add @nolock/ezdate

Using ezdate

Our current server location is "America/Sao_Paulo"

isBusinessDay

isBusinessDay(date: string | Date, hour: number, minute: number)

Parameters

date Opcional, default: new Date()

hour Opcional, default: 17

minute Opcional, default: 0

Example

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

getBusinessDay(date: string | Date)

Parameters

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

getNextBusinessDay(date: string | Date, days: number)

Parameters

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

getDate(date: string | Date)

Parameters

date Required

import {getDate} from '@nolock/ezdate'

console.log(getDate('2021-07-19'));
//2021-07-19T03:00:00.000Z

getYear

getYear(date: string | Date)

Parameters

date Opcional, default: new Date()

import {getYear} from '@nolock/ezdate'

console.log(getYear('2021-07-19'));
//2021

formatDate

formatDate(date: string | Date, type: TypeDate)

Parameters

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

getNationalHolidays(year: number)

Parameters

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

isHoliday(date: string | Date)

Parameters

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

License

@nolock/ezdate is MIT licensed.