Dates
Work with dates: calculate business days, date arithmetic, formatting, and age calculations.
Install the SDK
npm install @toolpouch/sdkView on npm →Import from this module
import { functionName } from '@toolpouch/sdk/dates'businessDaysBetween
Signature
businessDaysBetween(from: string, to: string): { businessDays: number; calendarDays: number; weekendDays: number }Calculate business days, calendar days, and weekend days between two dates.
Example
import { businessDaysBetween }from '@toolpouch/sdk/dates' ;const result = businessDaysBetween(' ,2026 -01 -01 '' );2026 -12 -31 '// { businessDays: 261 , calendarDays:364 , weekendDays:104 }
Returns
Object with businessDays, calendarDays, and weekendDays properties
daysBetween
Signature
daysBetween(from: string, to: string): numberGet the number of calendar days between two dates.
Example
import { daysBetween }from '@toolpouch/sdk/dates' ;const days = daysBetween(' ,2026 -01 -01 '' );2026 -01 -15 '// 14
Returns
Number of days
weeksBetween
Signature
weeksBetween(from: string, to: string): numberGet the number of weeks between two dates.
Example
import { weeksBetween }from '@toolpouch/sdk/dates' ;const weeks = weeksBetween(' ,2026 -01 -01 '' );2026 -02 -01 '// 4
Returns
Number of weeks
monthsBetween
Signature
monthsBetween(from: string, to: string): numberGet the number of months between two dates.
Example
import { monthsBetween }from '@toolpouch/sdk/dates' ;const months = monthsBetween(' ,2026 -01 -01 '' );2026 -12 -31 '// 11
Returns
Number of months
dateAdd
Signature
dateAdd(date: string, amount: number, unit: 'days' | 'weeks' | 'months' | 'years'): stringAdd a specified amount of time to a date.
Example
import { dateAdd }from '@toolpouch/sdk/dates' ;const future = dateAdd(' ,2026 -01 -01 '30 ,'days' );// ' 2026 -01 -31 '
Returns
ISO date string
dateFormat
Signature
dateFormat(date: string, format: 'iso' | 'us' | 'eu' | 'long'): stringFormat a date in different styles: ISO, US, EU, or long format.
Example
import { dateFormat }from '@toolpouch/sdk/dates' ;const formatted = dateFormat(' ,2026 -01 -15 ''long' );// 'January 15 ,2026 '
Returns
Formatted date string
isLeapYear
Signature
isLeapYear(year: number): booleanCheck if a year is a leap year.
Example
import { isLeapYear }from '@toolpouch/sdk/dates' ;const leap = isLeapYear(2024 );// true
Returns
Boolean indicating if the year is a leap year
weekNumber
Signature
weekNumber(date: string): numberGet the ISO week number for a date.
Example
import { weekNumber }from '@toolpouch/sdk/dates' ;const week = weekNumber(' );2026 -01 -15 '// 3
Returns
ISO week number (1-53)
age
Signature
age(birthDate: string): { years: number; months: number; days: number }Calculate age from a birth date.
Example
import { age }from '@toolpouch/sdk/dates' ;const result = age(' );1990 -05 -15 '// { years: 35 , months:4 , days:24 }
Returns
Object with years, months, and days properties
daysUntil
Signature
daysUntil(targetDate: string): numberCalculate days until a target date from today.
Example
import { daysUntil }from '@toolpouch/sdk/dates' ;const days = daysUntil(' );2027 -12 -31 '// 449
Returns
Number of days until the target date