mnth
Framework-agnostic base block to build calendars, datepickers, etc by rendering 2d array of Dates
Last updated 6 years ago by deepsweet .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install mnth 
SYNC missed versions from official npm registry.

mnth npm

Framework-agnostic base block to build calendars, datepickers, etc by rendering 2d array of Dates.

Install

$ yarn add mnth

Usage

type Options = {
  firstDayOfWeek: number // `1` (Monday) by default, Sunday is `0`, Saturday is `6`
}

getCalendarMonth(date: Date, options?: Options) => Date[][]
import { getCalendarMonth } from 'mnth'

const date = new Date('2018-04-01')
const calendarMonth = getCalendarMonth(date).map((week) =>
  week.map((day) => day.getDate())
)

console.log(calendarMonth)
/*
[
  [ 26, 27, 28, 29, 30, 31, 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, 1, 2, 3, 4, 5, 6 ]
]
*/

Current Tags

  • 2.0.0                                ...           latest (6 years ago)

7 Versions

  • 2.0.0                                ...           6 years ago
  • 1.0.1                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
  • 0.1.2                                ...           7 years ago
  • 0.1.1                                ...           8 years ago
  • 0.1.0                                ...           8 years ago
  • 0.1.0-0                                ...           8 years ago
Downloads
Today 0
This Week 1
This Month 6
Last Day 0
Last Week 5
Last Month 1
Dependencies (1)
Dev Dependencies (0)
None

Copyright 2013 - present © cnpmjs.org | Home |