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

calendar-month

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

calendar-month

vanillajs month data handler

  • 1.0.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
205
decreased by-40.23%
Maintainers
1
Weekly downloads
 
Created
Source

calendar-month

npm Build Status

node

npm i calendar-month --save

bower

bower i calendar-month --save
Examples
var Month = require('./month');

// startDay to set Monday as first week day
Month.setFirstWeekDay(1);

// months from 0 (january) ... to 11 (december)
new Month(2017, 5);

returns:

Month {
  meta: {
    date: '2017-06-01T00:00:00.000Z',
    last_day: 31,
    last_week_day: 3,
    week_day: 4,
    month_last_day: '2017-06-30T00:00:00.000Z'
  },
  year: 2017,
  month: 5,
  days: [
    { date: 29, month: 4, year: 2017, previous: true },
    { date: 30, month: 4, year: 2017, previous: true },
    { date: 31, month: 4, year: 2017, previous: true },
    { date: 1, month: 5, year: 2017, current: true },
    { date: 2, month: 5, year: 2017, current: true },
    { date: 3, month: 5, year: 2017, current: true },
    { date: 4, month: 5, year: 2017, current: true },
    { date: 5, month: 5, year: 2017, current: true },
    { date: 6, month: 5, year: 2017, current: true },
    { date: 7, month: 5, year: 2017, current: true },
    { date: 8, month: 5, year: 2017, current: true },
    { date: 9, month: 5, year: 2017, current: true },
    { date: 10, month: 5, year: 2017, current: true },
    { date: 11, month: 5, year: 2017, current: true },
    { date: 12, month: 5, year: 2017, current: true },
    { date: 13, month: 5, year: 2017, current: true },
    { date: 14, month: 5, year: 2017, current: true },
    { date: 15, month: 5, year: 2017, current: true },
    { date: 16, month: 5, year: 2017, current: true },
    { date: 17, month: 5, year: 2017, current: true },
    { date: 18, month: 5, year: 2017, current: true },
    { date: 19, month: 5, year: 2017, current: true },
    { date: 20, month: 5, year: 2017, current: true },
    { date: 21, month: 5, year: 2017, current: true },
    { date: 22, month: 5, year: 2017, current: true },
    { date: 23, month: 5, year: 2017, current: true },
    { date: 24, month: 5, year: 2017, current: true },
    { date: 25, month: 5, year: 2017, current: true },
    { date: 26, month: 5, year: 2017, current: true },
    { date: 27, month: 5, year: 2017, current: true },
    { date: 28, month: 5, year: 2017, current: true },
    { date: 29, month: 5, year: 2017, current: true },
    { date: 30, month: 5, year: 2017, current: true },
    { date: 1, month: 6, year: 2017, next: true },
    { date: 2, month: 6, year: 2017, next: true },
    { date: 3, month: 6, year: 2017, next: true },
    { date: 4, month: 6, year: 2017, next: true },
    { date: 5, month: 6, year: 2017, next: true },
    { date: 6, month: 6, year: 2017, next: true },
    { date: 7, month: 6, year: 2017, next: true },
    { date: 8, month: 6, year: 2017, next: true },
    { date: 9, month: 6, year: 2017, next: true }
  ]
}
previous(), next()
var Month = require('./month');

// months from 0 (january) ... to 11 (december)
var m = new Month(2017, 5);

m.previous();
// return equivalent to `new Month(2017, 4)`

m.next();
// return equivalent to `new Month(2017, 6)`

getColumns()

dates grouped by day of week

var Month = require('./month');

// startDay to set Sunday as first week day (default)
Month.setFirstWeekDay(0);

// months from 0 (january) ... to 11 (december)
new Month(2017, 5).getColumns();

returns:

[
  [
    { date: 28, month: 4, year: 2017, previous: true },
    { date: 4, month: 5, year: 2017, current: true },
    { date: 11, month: 5, year: 2017, current: true },
    { date: 18, month: 5, year: 2017, current: true },
    { date: 25, month: 5, year: 2017, current: true },
    { date: 2, month: 6, year: 2017, next: true }
  ],
  [
    { date: 29, month: 4, year: 2017, previous: true },
    { date: 5, month: 5, year: 2017, current: true },
    { date: 12, month: 5, year: 2017, current: true },
    { date: 19, month: 5, year: 2017, current: true },
    { date: 26, month: 5, year: 2017, current: true },
    { date: 3, month: 6, year: 2017, next: true }
  ],
  [
    { date: 30, month: 4, year: 2017, previous: true },
    { date: 6, month: 5, year: 2017, current: true },
    { date: 13, month: 5, year: 2017, current: true },
    { date: 20, month: 5, year: 2017, current: true },
    { date: 27, month: 5, year: 2017, current: true },
    { date: 4, month: 6, year: 2017, next: true }
  ],
  [
    { date: 31, month: 4, year: 2017, previous: true },
    { date: 7, month: 5, year: 2017, current: true },
    { date: 14, month: 5, year: 2017, current: true },
    { date: 21, month: 5, year: 2017, current: true },
    { date: 28, month: 5, year: 2017, current: true },
    { date: 5, month: 6, year: 2017, next: true }
  ],
  [
    { date: 1, month: 5, year: 2017, current: true },
    { date: 8, month: 5, year: 2017, current: true },
    { date: 15, month: 5, year: 2017, current: true },
    { date: 22, month: 5, year: 2017, current: true },
    { date: 29, month: 5, year: 2017, current: true },
    { date: 6, month: 6, year: 2017, next: true }
  ],
  [
    { date: 2, month: 5, year: 2017, current: true },
    { date: 9, month: 5, year: 2017, current: true },
    { date: 16, month: 5, year: 2017, current: true },
    { date: 23, month: 5, year: 2017, current: true },
    { date: 30, month: 5, year: 2017, current: true },
    { date: 7, month: 6, year: 2017, next: true }
  ],
  [
    { date: 3, month: 5, year: 2017, current: true },
    { date: 10, month: 5, year: 2017, current: true },
    { date: 17, month: 5, year: 2017, current: true },
    { date: 24, month: 5, year: 2017, current: true },
    { date: 1, month: 6, year: 2017, next: true },
    { date: 8, month: 6, year: 2017, next: true }
  ]
]

Keywords

FAQs

Package last updated on 10 Jan 2018

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