@slay-pics/date-utils
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

@slay-pics/date-utils

npm version npm downloads bundle Codecov

A handful of date utilities used on Slay.

Usage

Install package:

# npm
npm install @slay-pics/date-utils

# yarn
yarn add @slay-pics/date-utils

# pnpm
pnpm install @slay-pics/date-utils

# bun
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.

  • dayDiff(date1, date2)

Returns the difference between two dates in days

  • thisMonth(date)

Returns a date that is the 1st day of the month of the specified date.

  • previousMonth(date)

Returns a date that is the 1st day of the prior month of the specified date.

  • nextMonth(date)

Returns a date that is the 1st day of the next month of the specified date.

License

Published under MIT License.

Readme

Keywords

none

Package Sidebar

Install

npm i @slay-pics/date-utils

Weekly Downloads

6

Version

0.1.3

License

MIT

Unpacked Size

17.6 kB

Total Files

8

Last publish

Collaborators

  • slaypics