Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
lochungtin committed Jul 3, 2021
1 parent d4c2ed0 commit a0218e8
Showing 1 changed file with 51 additions and 1 deletion.
52 changes: 51 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,53 @@
# calendarJS
# CalendarJS

Simple calendar grid generator for NodeJS

## Install

With NPM

```npm install --save @enigmaoffline/calendarjs```

## Usage

```js
const Calendar = require('@enigmaoffline/calendarjs');

let cl = new Calendar(2020, 12);

console.log(cl.getGrid());
/* =>
[ [ '29-11-2020', '30-11-2020', '01-12-2020', '02-12-2020', '03-12-2020', '04-12-2020', '05-12-2020' ],
[ '06-12-2020', '07-12-2020', '08-12-2020', '09-12-2020', '10-12-2020', '11-12-2020', '12-12-2020' ],
[ '13-12-2020', '14-12-2020', '15-12-2020', '16-12-2020', '17-12-2020', '18-12-2020', '19-12-2020' ],
[ '20-12-2020', '21-12-2020', '22-12-2020', '23-12-2020', '24-12-2020', '25-12-2020', '26-12-2020' ],
[ '27-12-2020', '28-12-2020', '29-12-2020', '30-12-2020', '31-12-2020', '01-01-2021', '02-01-2021' ] ]
*/

console.log(cl.isLeapYear()); // => true

cl.nextMonth();

console.log(cl.getGrid());
/* =>
[ [ '27-12-2020', '28-12-2020', '29-12-2020', '30-12-2020', '31-12-2020', '01-01-2021', '02-01-2021' ],
[ '03-01-2021', '04-01-2021', '05-01-2021', '06-01-2021', '07-01-2021', '08-01-2021', '09-01-2021' ],
[ '10-01-2021', '11-01-2021', '12-01-2021', '13-01-2021', '14-01-2021', '15-01-2021', '16-01-2021' ],
[ '17-01-2021', '18-01-2021', '19-01-2021', '20-01-2021', '21-01-2021', '22-01-2021', '23-01-2021' ],
[ '24-01-2021', '25-01-2021', '26-01-2021', '27-01-2021', '28-01-2021', '29-01-2021', '30-01-2021' ],
[ '31-01-2021', '01-02-2021', '02-02-2021', '03-02-2021', '04-02-2021', '05-02-2021', '06-02-2021' ] ]
*/
```

### Static Usage

```js
const Calendar = require('@enigmaoffline/calendarjs');

console.log(Calendar.getDateNum(2020, 2)); // => 29
console.log(Calendar.getDateNum(2020, 3)); // => 31

console.log(Calendar.getNextMonth(2021, 12)); // => { month: 1, year: 2022 }
```

<a href="https://github.com/lochungtin/calendarJS/blob/master/LICENSE">LICENSE - MIT - Lo Chung Tin</a>

0 comments on commit a0218e8

Please sign in to comment.