@ts-utilkit/date
v0.2.0
Published
Date and time manipulation utilities for formatting, calculations, and timezone handling
Maintainers
Readme
@ts-utilkit/date
date Functions - TypeScript utility functions for date operations.
Installation
npm install @ts-utilkit/dateFeatures
- 🚀 TypeScript-first with complete type definitions
- ✅ Comprehensive test coverage (>95%)
- 📦 Tree-shakeable ESM and CommonJS support
- 🔒 Type-safe with strict TypeScript configuration
- 📖 Extensive JSDoc documentation
Available Functions (31)
addDays- Adds a specified number of days to a dateaddMonths- Adds a specified number of months to a datebusinessDaysBetween- Calculates business days between two datescalculateAge- Calculates age from date of birthcompareDates- Compares two dates (returns -1, 0, or 1)daysBetween- Calculates days between two datesdaysLeftInYear- Calculates days remaining in the yearformatDate- Formats a date according to a patterngetCurrentDateTimeISO- Gets current date/time in ISO 8601 formatgetDateParts- Extracts year, month, day components from dategetDaysInMonth- Gets the number of days in a specific monthgetDaysOfWeek- Gets all days of a specific weekgetEndOfMonth- Gets the last day of the monthgetEndOfWeek- Gets the end of the week (Sunday)getEndOfYear- Gets the last day of the year (Dec 31)getISOWeekDate- Gets ISO 8601 week date formatgetLastDayOfPreviousMonth- Gets the last day of previous monthgetNextMonth- Advances to next monthgetNextOccurrence- Finds next occurrence of a specific weekdaygetPreviousMonth- Goes back to previous monthgetQuarter- Gets the quarter of the year (1-4)getStartOfWeek- Gets the start of the week (Monday)getStartOfYear- Gets the first day of the year (Jan 1)getWeekNumber- Gets ISO week number (1-53)getWeekRange- Gets start and end dates of a weekgetWeekdaysInMonth- Gets all weekdays in a specific monthisLeapYear- Checks if a year is a leap yearisToday- Checks if a date is todayisWeekend- Checks if a date falls on a weekend (Sat/Sun)oneWeekAgo- Gets the date from one week agotoUTCDate- Converts a date to UTC
Quick Example
import { addDays, formatDate, daysBetween, isLeapYear } from '@ts-utilkit/date';
addDays(new Date(), 7); // Add 7 days
formatDate(new Date(), 'YYYY-MM-DD'); // Format date
daysBetween(date1, date2); // Days between dates
isLeapYear(2024); // trueLicense
MIT © Mykyta Forofontov
