Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

calendarize

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

calendarize

A tiny (196B) utility to generate calendar views

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8K
increased by193.94%
Maintainers
1
Weekly downloads
 
Created
Source

calendarize build status codecov

A tiny (196B) utility to generate calendar views.

This function (optionally) accepts a date in exchange for a calendar view of that date's month.

Additionally, this module is delivered as:

Install

$ npm install --save calendarize

Usage

via Date Instance

import calendarize from 'calendarize';

const date = new Date('2019-12-20');
const view = calendarize(date);
//=> [
//=>   [ 1,  2,  3,  4,  5,  6,  7],
//=>   [ 8,  9, 10, 11, 12, 13, 14],
//=>   [15, 16, 17, 18, 19, 20, 21],
//=>   [22, 23, 24, 25, 26, 27, 28],
//=>   [29, 30, 31,  0,  0,  0,  0],
//=> ]

via Date String

import calendarize from 'calendarize';

const view = calendarize('Nov 01, 2019');
//=> [
//=>   [ 0,  0,  0,  0,  0,  1,  2],
//=>   [ 3,  4,  5,  6,  7,  8,  9],
//=>   [10, 11, 12, 13, 14, 15, 16],
//=>   [17, 18, 19, 20, 21, 22, 23],
//=>   [24, 25, 26, 27, 28, 29, 30],
//=> ]

API

calendarize(date?)

Returns: Array<Week>

An Array of Week Arrays is returned.
Each Week is an Array of 7 numbers, each representing a numerical date.

Important: A zero (0) value represents a date that exists beyond the current month view.

date

Type: string | number | Date
Default: new Date() – aka, today

The date you want to process.

Important: Your string|number value will be cast to a Date object, which means Node.js may apply incorrect timezone!

License

MIT © Luke Edwards

Keywords

FAQs

Package last updated on 21 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc