Skip to main content
Home

Utility functions for working with dates

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
94%
Published
4 weeks ago (5.0.0)

default

Comprehensive date manipulation utilities for parsing, formatting, and date calculations. Includes functions for date conversion, boundary calculations, and date arithmetic. E.g. parseDate, isValidDate, convertStringDate, firstDateOfMonth

f
convertStringDate

Converts a string date from "dd/mm/yyyy hh:mm" format to "yyyy-mm-ddThh:mm" format. If the input string is empty, it returns an empty string. If the input string does not match the expected format, it returns an error.

T
DateFormat

Date format types supported by the parseDate function. The following formats are supported:

f
datification

Converts a string or a Date object into a Date object.

T
DurationAndReferenceDate

Type representing the parameter object for date-in-duration checks.

f
firstDateOfMonth

Returns the first date of the month for a given date.

f
isDateCompatible

Checks if the given value is compatible with Date.

f
isDateInDuration

Checks if the given date is within the duration from the reference date (inclusive).

f
isDateInLast12Months

Determines if a given date is within the last 12 months from the current date.

f
isDateInRange

Checks if the given date is within the given start and end dates (inclusive).

f
isDateInRangeOption

Checks if the given option is of type StartAndEndDate.

f
isDateInYear

Checks if the provided date string corresponds to a date in the specified year.

f
isValidDate

Checks if the given dates are valid.

f
isYearOption

Checks if the given option is of type Year.

f
lastDateOfMonth

Returns the last date of the month for a given date.

f
parseDate

Parses a date string in the specified format and returns a Date object.

f
sortByDate

Sorts objects by their date property.

T
StartAndEndDate

Type representing a start and end date (as Date types).

f
stringifyDate

Converts a Date object into a string in the format 'yyyy-mm-dd'.

T
YearOption

Type representing a year as an integer (number).

f
convertStringDate

Converts a string date from "dd/mm/yyyy hh:mm" format to "yyyy-mm-ddThh:mm" format. If the input string is empty, it returns an empty string. If the input string does not match the expected format, it returns an error.

f
datification

Converts a string or a Date object into a Date object.

f
firstDateOfMonth

Returns the first date of the month for a given date.

f
isDateCompatible

Checks if the given value is compatible with Date.

T
DurationAndReferenceDate

Type representing the parameter object for date-in-duration checks.

f
isDateInDuration

Checks if the given date is within the duration from the reference date (inclusive).

f
isDateInLast12Months

Determines if a given date is within the last 12 months from the current date.

f
isDateInRange

Checks if the given date is within the given start and end dates (inclusive).

f
isDateInRangeOption

Checks if the given option is of type StartAndEndDate.

T
StartAndEndDate

Type representing a start and end date (as Date types).

f
isDateInYear

Checks if the provided date string corresponds to a date in the specified year.

f
isYearOption

Checks if the given option is of type Year.

T
YearOption

Type representing a year as an integer (number).

f
isValidDate

Checks if the given dates are valid.

f
lastDateOfMonth

Returns the last date of the month for a given date.

T
DateFormat

Date format types supported by the parseDate function. The following formats are supported:

f
parseDate

Parses a date string in the specified format and returns a Date object.

f
sortByDate

Sorts objects by their date property.

f
stringifyDate

Converts a Date object into a string in the format 'yyyy-mm-dd'.

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.