Common date range presets

Import

import { ... } from 'ts-time-utils/rangePresets';

Examples

Date Range Presets

Quick access to common date ranges

import {
  today, yesterday, tomorrow,
  lastNDays, nextNDays,
  thisWeek, lastWeek, nextWeek,
  thisMonth, lastMonth, nextMonth,
  thisQuarter, thisYear
} from 'ts-time-utils/rangePresets';

// Today's range (start to end of day)
const todayRange = today();
console.log('Today:', todayRange.start, '-', todayRange.end);

// Yesterday and tomorrow
console.log('Yesterday:', yesterday().start.toDateString());
console.log('Tomorrow:', tomorrow().start.toDateString());

// Last N days
const last7 = lastNDays(7);
console.log('Last 7 days:', last7.start.toDateString(), '-', last7.end.toDateString());

// Next N days
const next30 = nextNDays(30);
console.log('Next 30 days:', next30.start.toDateString(), '-', next30.end.toDateString());

// Week ranges
console.log('This week:', thisWeek().start.toDateString());
console.log('Last week:', lastWeek().start.toDateString());
console.log('Next week:', nextWeek().start.toDateString());

// Month ranges
console.log('This month:', thisMonth().start.toDateString());
console.log('Last month:', lastMonth().start.toDateString());

// Quarter and year
console.log('This quarter:', thisQuarter().start.toDateString());
console.log('This year:', thisYear().start.toDateString());