simple-calendar-generator
v1.2.0
Published
No dependencies simple calendar
Downloads
3
Readme
simple-calendar
v1.1.0 export type Day = { date: Date, isNextMonth: boolean, isPrevMonth: boolean } Input type: Date Return type: { [key: string]: Array< Day > }
Install
Install with npm:
$ npm install --save simple-calendar-generator
Usage
const calendar = new Calendar(new Date(Date.now()))
const matrix = calendar.getMatrix()
// Result. Each item of array is a date.
// you can format it any way you want
matrix = {
"week_1": [
{
"date": "2021-03-27T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": true
},
{
"date": "2021-03-28T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": true
},
{
"date": "2021-03-29T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": true
},
{
"date": "2021-03-30T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": true
},
{
"date": "2021-03-31T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": false
},
{
"date": "2021-04-01T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": false
},
{
"date": "2021-04-02T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": false
}
],
"week_2": [
{
"date": "2021-04-03T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": false
},
{
"date": "2021-04-04T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": false
},
{
"date": "2021-04-05T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": false
},
{
"date": "2021-04-06T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": false
},
{
"date": "2021-04-07T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": false
},
{
"date": "2021-04-08T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": false
},
{
"date": "2021-04-09T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": false
}
],
"week_3": [
{
"date": "2021-04-10T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": false
},
{
"date": "2021-04-11T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": false
},
{
"date": "2021-04-12T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": false
},
{
"date": "2021-04-13T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": false
},
{
"date": "2021-04-14T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": false
},
{
"date": "2021-04-15T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": false
},
{
"date": "2021-04-16T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": false
}
],
"week_4": [
{
"date": "2021-04-17T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": false
},
{
"date": "2021-04-18T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": false
},
{
"date": "2021-04-19T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": false
},
{
"date": "2021-04-20T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": false
},
{
"date": "2021-04-21T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": false
},
{
"date": "2021-04-22T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": false
},
{
"date": "2021-04-23T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": false
}
],
"week_5": [
{
"date": "2021-04-24T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": false
},
{
"date": "2021-04-25T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": false
},
{
"date": "2021-04-26T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": false
},
{
"date": "2021-04-27T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": false
},
{
"date": "2021-04-28T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": false
},
{
"date": "2021-04-29T21:00:00.000Z",
"isNextMonth": false,
"isPrevMonth": false
},
{
"date": "2021-04-30T21:00:00.000Z",
"isNextMonth": true,
"isPrevMonth": false
}
],
"week_6": [
{
"date": "2021-05-01T21:00:00.000Z",
"isNextMonth": true,
"isPrevMonth": false
},
{
"date": "2021-05-02T21:00:00.000Z",
"isNextMonth": true,
"isPrevMonth": false
},
{
"date": "2021-05-03T21:00:00.000Z",
"isNextMonth": true,
"isPrevMonth": false
},
{
"date": "2021-05-04T21:00:00.000Z",
"isNextMonth": true,
"isPrevMonth": false
},
{
"date": "2021-05-05T21:00:00.000Z",
"isNextMonth": true,
"isPrevMonth": false
},
{
"date": "2021-05-06T21:00:00.000Z",
"isNextMonth": true,
"isPrevMonth": false
},
{
"date": "2021-05-07T21:00:00.000Z",
"isNextMonth": true,
"isPrevMonth": false
}
]
}
Author
Roman Constantin
License
(MIT)