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

moment-loyall

v1.3.0

Published

Moment.js extended

Downloads

3,474

Readme

Moment Loyall

It's an extended version of moment-timezone package with extra functions.

Moment.js

It extends the moment-timezone, so we have all the built in functions and a few more.

How to use it

$ npm i -S moment-loyall

Then just import as a normal module

import moment from "moment-loyall";

moment();

Holidays - isHoliday

Moment Loyall has all Brazil National Holidays and São Paulo specific holidays for the stock marketing. The parameter Holiday Calendar is required, see the avaiable list bellow:

  • "sp": B3 and National Holidays
  • "brasil": Only National Holidays
  • "us": United States National Holidays
  • "mexico": Mexico National Holidays
  • "uk": United Kingdom National Holidays
  • "argentina": Argentina National Holidays
  • "france": France National Holidays
  • "italy": Italy National Holidays
  • "swiss": Switzerland National Holidays
  • "spain": Spain National Holidays
const isHoliday = moment("2020-12-25").isHoliday("brasil");
// isHoliday = true

Holidays - getHolidays

Gets an array of holidays

const holidays = moment().getHolidays("sp");
// holidays = [ '2020-12-25', ...]

Business Day - isBusinessDay

Check if date is a business day

const holidays = moment("2020-04-14").isBusinessDay("brasil");
// true

Business Day - nextBusinessDay

Get date next business day

const holidays = moment("2020-04-14").nextBusinessDay("brasil");
// 2020-04-15

Business Day - prevBusinessDay

Get date previous business day

const holidays = moment("2020-04-14").nextBusinessDay("brasil");
// 2020-04-13

Business Day - businessAdd

Add period off business day form the date

const holidays = moment("2020-04-14").businessAdd(2, "days", "brasil");
// 2020-04-16

Business Day - businessSubtract

Subtract period off business day form the date

const holidays = moment("2020-04-10").businessSubtract(2, "days", "brasil");
// 2020-04-16

Business Day - businessDiff

Get the number off business day between two dates

const holidays = moment("2020-04-10").businessDiff(moment("2020-04-01"), "brasil");
// 8

/**
 * To return an array of dates you need to pass a third argument
 */
const holidays = moment("2020-04-10").businessDiff(moment("2020-04-01"), "brasil", true);
// [ '2020-04-01',
//  '2020-04-02',
//  '2020-04-03',
//  '2020-04-06',
//  '2020-04-07',
//  '2020-04-08',
//  '2020-04-09',
//  '2020-04-13' ]

Relative dates - moment.parseRelativeDate

Parse D-* notation (D0, D-1, D+1, etc)

// Suppose today is 2020-04-14
const targetDate = moment.parseRelativeDate("D0");
// 2020-04-14

const targetDate2 = moment.parseRelativeDate("D+1");
// 2020-04-15

const targetDate3 = moment.parseRelativeDate("D-2");
// 2020-04-12

// ISO dates are also supported
const targetDate4 = moment.parseRelativeDate("2020-05-15");
// 2020-05-15

Relative dates - moment.parseRelativeBusinessDate

Parse D-* notation (D0, D-1, D+1, etc) using only business days

// Suppose today is 2020-04-14
const targetDate = moment.parseRelativeBusinessDate("D0", "brasil");
// 2020-04-14

const targetDate2 = moment.parseRelativeBusinessDate("D+1", "brasil");
// 2020-04-15

const targetDate3 = moment.parseRelativeBusinessDate("D-2", "brasil");
// 2020-04-10

// ISO dates are also supported
const targetDate4 = moment.parseRelativeBusinessDate("2020-05-15", "brasil");
// 2020-05-15