Giter Club home page Giter Club logo

calendar-data's Introduction

Note ℹī¸

From version 1.0.23 the library supports both node and browser environments.

And can be used on both client and server side components.

calendar-data


Install using NPM

npm i calendar-data

Install using Yarn

yarn add calendar-data

Video

calendar-data.mp4

Open on Youtube

Overview

TypeScript library that provides an easy-to-use and intuitive utility functions for retrieving calendar data. These functions aim to help you generate the data you need for a calendar in two ways - monthly or yearly based.

  1. Monthly data retrieval happens via: getDaysInMonth
  2. Yearly data retrieval happens via: getYearData

Usage

Importing the Library

import { getDaysInMonth, getYearData } from 'calendar-data';

Fn 1: getDaysInMonth

getDaysInMonth(2021, 6, 'Mon');

// returns
{
    "daysInMonth": [
        {
            "yearNumber": 2021,
            "monthNumber": 6,
            "dayNumberInMonth": null,
            "isWeekendDay": false
        },
        {
            "yearNumber": 2021,
            "monthNumber": 6,
            "dayNumberInMonth": 1,
            "isWeekendDay": false
        },

        ....

        {
            "yearNumber": 2021,
            "monthNumber": 6,
            "dayNumberInMonth": 30,
            "isWeekendDay": false
        },
        {
            "yearNumber": 2021,
            "monthNumber": 6,
            "dayNumberInMonth": null,
            "isWeekendDay": false
        },
        {
            "yearNumber": 2021,
            "monthNumber": 6,
            "dayNumberInMonth": null,
            "isWeekendDay": false
        },
        {
            "yearNumber": 2021,
            "monthNumber": 6,
            "dayNumberInMonth": null,
            "isWeekendDay": false
        },
        {
            "yearNumber": 2021,
            "monthNumber": 6,
            "dayNumberInMonth": null,
            "isWeekendDay": false
        }
    ],
    "weekDaysStrings": [
        "Mon",
        "Tue",
        "Wed",
        "Thu",
        "Fri",
        "Sat",
        "Sun"
    ]
}

Fn 2: getYearData

getYearData(2021, 'Mon');

// returns
// The returned data is the same as getDaysInMonth but for all the months
{
  1:  {
        "daysInMonth": ...
        "weekDaysStrings": ...
      }

    ...

  12: {
        "daysInMonth": ...
        "weekDaysStrings": ...
      }
}

calendar-data's People

Contributors

merhanmustafov avatar

Watchers

 avatar  avatar

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.