
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
@eperedo/calendar-hooks
Advanced tools
Basic hooks for calendar components
yarn add calendar-hooks
import React from 'react';
import useCalendar from 'calendar-hooks';
function CustomCalendar() {
const { year, month, day, days, changeDate } = useCalendar(new Date());
function onClick(day) {
changeDate(day.date);
}
function onChangeMonth(action) {
if (action === 'prev') {
const newMonth = (month.number - 1) - 1;
changeDate(new Date(year, newMonth, day.number, 0, 0, 0));
} else {
const newMonth = (month.number + 1) - 1;
changeDate(new Date(year, newMonth, day.number, 0, 0, 0));
}
}
return (
<div>
<div>Selected Day: {day.name} - {day.number}</div>
<div>Current Year: {year}</div>
<div>
<button type="button" onClick={() => onChangeMonth('prev')}>
Prev
</button>
<p>Current Month: {month.name}</p>
<button type="button" onClick={() => onChangeMonth('next')}>
Next
</button>
</div>
<div>
{days.map((day) => {
return (
<button type="button" onClick={(e) => changeDate(day)} key={day.number}>
{day.number}
</button>
);
})}
</div>
</div>
);
}
export default CustomCalendar;
Generate an object with calendar information
Returns:
{ day, days, month, year, changeDate }
{
name: 'Monday',
abbr: 'Mon',
number: 2,
}
[
{
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,
},
]
{
name: 'July',
number: 7,
jsNumber: 6,
}
2019
FAQs
> Basic hooks for calendar components
We found that @eperedo/calendar-hooks demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.