Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@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.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.