calendar-data
v1.0.23
Published
Generate calendar data effortlessly using intuitive utility functions.
Downloads
28
Readme
Note :information_source:
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
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.
- Monthly data retrieval happens via:
getDaysInMonth
- 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": ...
}
}