@slay-pics/date-utils
A handful of date utilities used on Slay.
Usage
Install package:
npm install @slay-pics/date-utils
yarn add @slay-pics/date-utils
pnpm install @slay-pics/date-utils
bun install @slay-pics/date-utils
Usage
addYears(date, amount)
addMonths(date, amount)
addDays(date, amount)
addHours(date, amount)
addMinutes(date, amount)
addSeconds(date, amount)
Adds the specified amount of units to a date. Date can be a string, a JS date or null. If null is passed, then the current date
is used.
isPast(date)
isFuture(date)
Determines if the given date occurs in the past or future.
isWithinYears(date, amount)
isWithinMonths(date, amount)
isWithinDays(date, amount)
isWithinHours(date, amount)
isWithinMinutes(date, amount)
isWithinSeconds(date, amount)
Determines if the specified date is within the given range of the current date.
Returns the difference between two dates in days
Returns a date that is the 1st day of the month of the specified date.
Returns a date that is the 1st day of the prior month of the specified date.
Returns a date that is the 1st day of the next month of the specified date.
License
Published under MIT License.