Neo Zero

date

Pool

Zero-dependency date library - Tree-shakeable alternative to date-fns and moment.js

$ lpm install @lpm.dev/neo.date
28 exportsTypeScript

dist

Functions

format
function format(date: Date, options?: FormatOptions): string

Format date using Intl.DateTimeFormat Leverages native Intl API for locale-aware formatting Zero dependencies, all formatting done natively

ParameterTypeDescription
date
Date- Date to format
optionsoptional
FormatOptions- Formatting options
formatISO
function formatISO(date: Date, options?: ISOFormatOptions): string

Format date as ISO 8601 string

ParameterTypeDescription
date
Date- Date to format
optionsoptional
ISOFormatOptions- ISO options
formatRelative
function formatRelative(date: Date, baseDate?: Date, options?: RelativeTimeOptions): string

Format date as relative time ("2 hours ago", "in 3 days") Uses Intl.RelativeTimeFormat for locale-aware relative formatting

ParameterTypeDescription
date
Date- Date to format
baseDateoptional
Date- Base date to compare against (defaults to now)
optionsoptional
RelativeTimeOptions- Relative time options
parseISO
function parseISO(dateString: string): Date

Parse ISO 8601 date string Supports ISO 8601 and RFC 3339 formats

ParameterTypeDescription
dateString
string- ISO 8601 or RFC 3339 string
add
function add(date: Date, duration: Duration): Date

Add duration to date (immutable)

ParameterTypeDescription
date
Date- Date to add to
duration
Duration- Duration to add
subtract
function subtract(date: Date, duration: Duration): Date

Subtract duration from date (immutable)

ParameterTypeDescription
date
Date- Date to subtract from
duration
Duration- Duration to subtract
startOf
function startOf(date: Date, unit: 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second'): Date

Get start of time unit (immutable)

ParameterTypeDescription
date
Date- Date to operate on
unit
'year' | 'month' | 'day' | 'hour' | 'minute' | 'second'- Time unit ('year', 'month', 'day', 'hour', 'minute', 'second')
endOf
function endOf(date: Date, unit: 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second'): Date

Get end of time unit (immutable)

ParameterTypeDescription
date
Date- Date to operate on
unit
'year' | 'month' | 'day' | 'hour' | 'minute' | 'second'- Time unit
isValid
function isValid(date: Date): boolean

Check if date is valid

ParameterTypeDescription
date
Date- Date to validate
diff
function diff(dateLeft: Date, dateRight: Date, unit: 'years' | 'months' | 'days' | 'hours' | 'minutes' | 'seconds' | 'milliseconds'): number

Calculate difference between dates

ParameterTypeDescription
dateLeft
Date- Later date
dateRight
Date- Earlier date
unit
'years' | 'months' | 'days' | 'hours' | 'minutes' | 'seconds' | 'milliseconds'- Unit to return difference in
compare
function compare(dateLeft: Date, dateRight: Date): number

Compare two dates

ParameterTypeDescription
dateLeft
Date- First date
dateRight
Date- Second date
isEqual
function isEqual(dateLeft: Date, dateRight: Date): boolean

Check if dates are equal

ParameterTypeDescription
dateLeft
Date- First date
dateRight
Date- Second date
isBefore
function isBefore(date: Date, dateToCompare: Date): boolean

Check if date is before another

ParameterTypeDescription
date
Date- Date to check
dateToCompare
Date- Date to compare against
isAfter
function isAfter(date: Date, dateToCompare: Date): boolean

Check if date is after another

ParameterTypeDescription
date
Date- Date to check
dateToCompare
Date- Date to compare against

dist

Functions

format
function format(date: Date, options?: FormatOptions): string

Format date using Intl.DateTimeFormat Leverages native Intl API for locale-aware formatting Zero dependencies, all formatting done natively

ParameterTypeDescription
date
Date- Date to format
optionsoptional
FormatOptions- Formatting options
formatISO
function formatISO(date: Date, options?: ISOFormatOptions): string

Format date as ISO 8601 string

ParameterTypeDescription
date
Date- Date to format
optionsoptional
ISOFormatOptions- ISO options
formatRelative
function formatRelative(date: Date, baseDate?: Date, options?: RelativeTimeOptions): string

Format date as relative time ("2 hours ago", "in 3 days") Uses Intl.RelativeTimeFormat for locale-aware relative formatting

ParameterTypeDescription
date
Date- Date to format
baseDateoptional
Date- Base date to compare against (defaults to now)
optionsoptional
RelativeTimeOptions- Relative time options
parseISO
function parseISO(dateString: string): Date

Parse ISO 8601 date string Supports ISO 8601 and RFC 3339 formats

ParameterTypeDescription
dateString
string- ISO 8601 or RFC 3339 string
add
function add(date: Date, duration: Duration): Date

Add duration to date (immutable)

ParameterTypeDescription
date
Date- Date to add to
duration
Duration- Duration to add
subtract
function subtract(date: Date, duration: Duration): Date

Subtract duration from date (immutable)

ParameterTypeDescription
date
Date- Date to subtract from
duration
Duration- Duration to subtract
startOf
function startOf(date: Date, unit: 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second'): Date

Get start of time unit (immutable)

ParameterTypeDescription
date
Date- Date to operate on
unit
'year' | 'month' | 'day' | 'hour' | 'minute' | 'second'- Time unit ('year', 'month', 'day', 'hour', 'minute', 'second')
endOf
function endOf(date: Date, unit: 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second'): Date

Get end of time unit (immutable)

ParameterTypeDescription
date
Date- Date to operate on
unit
'year' | 'month' | 'day' | 'hour' | 'minute' | 'second'- Time unit
isValid
function isValid(date: Date): boolean

Check if date is valid

ParameterTypeDescription
date
Date- Date to validate
diff
function diff(dateLeft: Date, dateRight: Date, unit: 'years' | 'months' | 'days' | 'hours' | 'minutes' | 'seconds' | 'milliseconds'): number

Calculate difference between dates

ParameterTypeDescription
dateLeft
Date- Later date
dateRight
Date- Earlier date
unit
'years' | 'months' | 'days' | 'hours' | 'minutes' | 'seconds' | 'milliseconds'- Unit to return difference in
compare
function compare(dateLeft: Date, dateRight: Date): number

Compare two dates

ParameterTypeDescription
dateLeft
Date- First date
dateRight
Date- Second date
isEqual
function isEqual(dateLeft: Date, dateRight: Date): boolean

Check if dates are equal

ParameterTypeDescription
dateLeft
Date- First date
dateRight
Date- Second date
isBefore
function isBefore(date: Date, dateToCompare: Date): boolean

Check if date is before another

ParameterTypeDescription
date
Date- Date to check
dateToCompare
Date- Date to compare against
isAfter
function isAfter(date: Date, dateToCompare: Date): boolean

Check if date is after another

ParameterTypeDescription
date
Date- Date to check
dateToCompare
Date- Date to compare against
Unlimited AccessInstall as many Pool packages as you need.
Fund Real WorkEvery install you run sends revenue directly to the developer who built it.

Taxes calculated at checkout based on your location.

Weekly Installs
3
Version
1.0.0
Published
LicenseMIT
Size61.38 KB
Files10
Node version>= 18
TypeScriptYes