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

calenda

v1.0.4

Published

A solution for your date management. We've abstracted the complexities of calculating dates for you to use through our easy to use light-weight API. Build your time management apps faster.

Downloads

15

Readme

A solution for your date management. We've abstracted the complexities of calculating dates for you to use through our easy to use light-weight library. Build your time management apps faster.

Sample

Head over to the official website for an interactive demonstration.

How it works

Step 1: Initialization

  • Run the command
npm i calenda
  • Import calenda into your project
Import Calenda from 'calenda'
  • Create a new Calendar instance and pass in an object with a month property set to any month of the year.

Note: The year defaults to the current year you are in.

const calendar = new Calenda({
  month: 'January'
});

Step 2: Get the month structure

  • Call the getStructure method on the instance and get the structure property.
calendar.getStructure().structure;

This returns an object of arrays with the days of the week as keys and an array of numbers as values which are the days of the month that fall on that day of the week.

{
  Sun: [ 0, 3, 10, 17, 24, 31 ],
  Mon: [ 0, 4, 11, 18, 25 ],
  Tue: [ 0, 5, 12, 19, 26 ],
  Wed: [ 0, 6, 13, 20, 27 ],
  Thu: [ 0, 7, 14, 21, 28 ],
  Fri: [ 1, 8, 15, 22, 29 ],
  Sat: [ 2, 9, 16, 23, 30 ]
}

Step 3: Get information

  • Chain the getInfo method with the getStructure method and passing in a day of the month as a number as he first argument and an object with a set of options specifying the information you would like to get as the second argument.
calendar.getStructure().getInfo(1, {
  dayNumber: true,
  dayOfWeek: true,
  monthOfYear: true,
  year: true,
  suffix: true
})

This returns an object with the values of the specified options.

{
   dayNumber: 1,
   dayOfWeek: 'Fri',
   monthOfYear: 'January',
   year: 2021,
   suffix: 'st'
}

Step 4: Time travel

  • You can move forward or backward from the current month by calling the moveMonth method on the calendar object with either forward or backward as a string argument on the method. This method can be chained with other methods including itself to get your desired results.
calendar.moveMonth('forward').getStructure().getInfo(1, {
  dayNumber: true,
  dayOfWeek: true,
  monthOfYear: true,
  year: true,
  suffix: true
})

This returns an object with the values of the specified options of the next month February.

{
   dayNumber: 1,
   dayOfWeek: 'Mon',
   monthOfYear: 'February',
   year: 2021,
   suffix: 'st'
}

The same applies for moving backwards.

Additional information

Support us

Contribute

Sponsor