Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/merhanmustafov/calendar-data
Library that provides calendar data generation utility functions
https://github.com/merhanmustafov/calendar-data
calendar npm-package npmjs typescript utilities webpack
Last synced: 7 days ago
JSON representation
Library that provides calendar data generation utility functions
- Host: GitHub
- URL: https://github.com/merhanmustafov/calendar-data
- Owner: MerhanMustafov
- Created: 2024-01-03T14:59:43.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-07T12:32:34.000Z (5 months ago)
- Last Synced: 2025-01-18T20:01:07.098Z (7 days ago)
- Topics: calendar, npm-package, npmjs, typescript, utilities, webpack
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/calendar-data
- Size: 355 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
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
[Video](https://github.com/MerhanMustafov/calendar-data/assets/76586375/d4f5ac7c-5b57-405f-b2c4-1afbe62a27d6)
[Open on Youtube](https://www.youtube.com/watch?v=WGA6uzkSRbk)
## 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
```typescript
import { getDaysInMonth, getYearData } from 'calendar-data';
```### Fn 1: `getDaysInMonth`
```typescript
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`
```typescript
getYearData(2021, 'Mon');// returns
// The returned data is the same as getDaysInMonth but for all the months
{
1: {
"daysInMonth": ...
"weekDaysStrings": ...
}...
12: {
"daysInMonth": ...
"weekDaysStrings": ...
}
}
```