0.0.4 • Published 7 months ago
js-daterange v0.0.4
Date Range Utils
A utility package for handling date ranges across different timezones.
Installation
npm install @yourusername/date-range-utils
Usage
import { Period, DateFormat, DateRange } from '@yourusername/date-range-utils';
// Create a Period instance with a specific timezone and date format
const period = new Period('America/New_York', DateFormat.YYYY_MM_DD);
// Get date range for last month
const lastMonthRange = period.createDefinedRange(DateRange.LAST_MONTH);
// Create a custom date range (e.g., last 7 days including today)
const customRange = period.createCustomRange(7, true);
Methods
createDefinedRange(dateRange: DateRange)
: Get predefined date rangescreateCustomRange(prevDays: number, includingToday: boolean)
: Create custom date rangesgetOffset(timeZone: string)
: Get timezone offset
License
MIT