Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
A minimal high performance date library for Node.js and Browser. Use it to compare and manipulate dates.
npm install instadate
var instadate = require('instadate');
var date1 = new Date();
var date2 = instadate.addDays(date1, 1);
instadate.differenceInDates(date1, date2);
Current popular date libraries put a lot of effort into doing a lot causing them to lose a lot of performance because of heavy abstractions. Instadate on the other hand only has a handful of features that are all geared towards performance. Instadate is more of a wrapper around the native JavaScript Date than a full on date library.
Use Instadate when you need to run thousands of date manipulations or comparisons per second. Instadate is managed and used by Teamweek team calendar.
Instadate..
utc(date)
Returns the UTC time in milliseconds.
noon(date)
Returns a copy of the date with hours set to 12 and minutes, seconds and milliseconds set to 0.
differenceInDays(from, to)
Returns the difference in days (24 hour periods) between two dates. Returned result can be negative.
differenceInHours(from, to)
Returns the difference in hours (60 minute periods) between two dates. Returned result can be negative.
differenceInMinutes(from, to)
Returns the difference in minutes (60 second periods) between two dates. Returned result can be negative.
differenceInSeconds(from, to)
Returns the difference in seconds (1000 milisecond periods) between two dates. Returned result can be negative.
differenceInWeekendDays(from, to)
Returns the difference in days (24 hour periods) between two dates. Excludes work days. Returned result can be negative.
differenceInWorkDays(from, to)
Returns the difference in days (24 hour periods) between two dates. Excludes weekend days. Returned result can be negative.
differenceInDates(from, to)
Similar to differenceInDays
however counts all dates that fit into the period, not 24 hour periods.
addDays(date, days)
Returns a cloned date with days added to it, use negative input for subtraction.
addHours(date, hours)
Returns a cloned date with hours added to it, use negative input for subtraction.
addMinutes(date, minutes)
Returns a cloned date with minutes added to it, use negative input for subtraction.
addSeconds(date, seconds)
Returns a cloned date with seconds added to it, use negative input for subtraction.
addMilliseconds(date, milliseconds)
Returns a cloned date with milliseconds added to it, use negative input for subtraction.
isSameYear(date1, date2)
Returns if the years are equal
isSameMonth(date1, date2)
Returns if the years and months are equal
isSameDay(date1, date2)
Returns if the years, months and dates are equal
equal(date1, date2)
Returns if the dates are equal to millisecond precision
min(date1, date2)
Returns the earliest date
max(date1, date2)
Returns the latest date
dates(start, end)
Returns all dates within start and end period. Uses differenceInDates
internally.
dateString(date)
Returns the date part of a Date as a string. Example: Mon Jan 25 2016
.
isoDateString(date)
Returns the date part of an iso Date as a string. Example: 2016-01-25
.
firstDateInMonth(date)
Returns the first date of the month.
lastDateInMonth(date)
Returns the last date of the month.
isWeekendDay(day)
Checks if the given day (0-6) is a weekend day.
isWorkDay(day)
Checks if the given day (0-6) is a work day.
isWeekendDate(date)
Checks if the given date is a weekend day.
isWorkDate(date)
Checks if the given date is a work day.
setWeekendDays(daysArray)
Sets the given days (array containing integers from 0 to 6) as weekend days. Any day not in the array will be set as a work day. After the weekend days are set all Instadate functions will use the new work and weekend days.
daysInPeriod(firstDay, length, daysArray)
Counts the days defined in daysArray within the given period.
weekendDaysInPeriod(firstDay, length)
Counts weekend days within period.
workDaysInPeriod(firstDay, length)
Counts work days within period.
isYearAfter(date1, date2)
Checks if date1 year is after date2 year.
isMonthAfter(date1, date2)
Checks if date1 month is after date2 month.
isDayAfter(date1, date2)
Checks if date1 date is after date2 date.
isYearBefore(date1, date2)
Checks if date1 year is before date2 year.
isMonthBefore(date1, date2)
Checks if date1 month is before date2 month.
isDayBefore(date1, date2)
Checks if date1 date is before date2 date.
isYearBetween(date1, date2, date3)
Checks if date1 year is between date2 and date3 years.
isMonthBetween(date1, date2, date3)
Checks if date1 month is between date2 and date3 months.
isDayBetween(date1, date2, date3)
Checks if date1 is between date2 and date3.
isoWeekDay(day)
Converts day (0-6) to iso day (1-7).
npm test
FAQs
A minimal high performance date library for Node.js and Browser
We found that instadate 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
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.