Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@eperedo/calendar-hooks

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eperedo/calendar-hooks - npm Package Compare versions

Comparing version 0.11.0 to 0.14.0

2

package.json
{
"name": "@eperedo/calendar-hooks",
"version": "0.11.0",
"version": "0.14.0",
"main": "./src/hooks/index.js",

@@ -5,0 +5,0 @@ "peerDependencies": {

@@ -16,3 +16,3 @@ > Basic hooks for calendar components

function CustomCalendar() {
const { year, month, days, changeDate } = useCalendar(new Date());
const { year, month, day, days, changeDate } = useCalendar(new Date());

@@ -25,6 +25,6 @@ function onClick(day) {

if (action === 'prev') {
const newMonth = month.number - 1 - 1;
const newMonth = (month.number - 1) - 1;
changeDate(new Date(year, newMonth, day.number, 0, 0, 0));
} else {
const newMonth = month.number + 1 - 1;
const newMonth = (month.number + 1) - 1;
changeDate(new Date(year, newMonth, day.number, 0, 0, 0));

@@ -50,3 +50,3 @@ }

return (
<button onClick={(e) => changeDate(day.date)} key={day.number}>
<button type="button" onClick={(e) => changeDate(day)} key={day.number}>
{day.number}

@@ -63,1 +63,64 @@ </button>

```
### API
### useCalendar(selectedDate)
Generate an object with calendar information
- selectedDate: A valid javascript date object
Returns:
`{ day, days, month, year, changeDate }`
- day: an object with information about the day of the **selectedDate** parameter
```js
{
name: 'Monday',
abbr: 'Mon',
number: 2,
}
```
- days: an array with all days of one month
```js
[
{
date: 'Sun Jul 07 2019 13:17:38 GMT-0500 (Peru Standard Time)', // a valid js date object
isToday: false,
number: 1,
},
{
date: 'Mon Jul 08 2019 13:17:38 GMT-0500 (Peru Standard Time)', // a valid js date object
isToday: true,
number: 2,
},
// until last day of the month
{
date: 'Mon Jul 31 2019 13:17:38 GMT-0500 (Peru Standard Time)', // a valid js date object
isToday: false,
number: 31,
},
]
```
- month: an object with information about the month of the **selectedDate** parameter
```js
{
name: 'July',
number: 7,
jsNumber: 6,
}
```
- year: the year of the **selectedDate** parameter
```js
2019
```
- changeDate(selectedDate): a function that mutates the **selectedDate** value
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc