0.1.3 • Published 1 year ago

@slay-pics/date-utils v0.1.3

Weekly downloads
-
License
MIT
Repository
bitbucket
Last release
1 year ago

@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.

0.1.3

1 year ago

0.1.2

2 years ago

0.1.1

2 years ago