Coder Social home page Coder Social logo

lochungtin / calendarjs Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 8 KB

Simple calendar generator for NodeJS

Home Page: https://www.npmjs.com/package/@enigmaoffline/calendarjs

License: MIT License

TypeScript 100.00%
calendar calendar-generator nodejs

calendarjs's Introduction

CalendarJS

Simple calendar grid generator for NodeJS

Install

With NPM

npm install --save @enigmaoffline/calendarjs

Usage

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

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 }

LICENSE - MIT - Lo Chung Tin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.