daterange
A library for generating past date ranges as a simple wrapper around date-fns
Installation
npm i -S @devtanc/daterange
yarn add @devtanc/daterange
Usage
Calendar Ranges
This function is for generating ranges in the past that conform to calendar units like days, weeks, months, quarters, or years. This library does not currently handle ranges in the future. The return object is in the form of:
{
start: Date,
end: Date
}
import {
getCalendarRange,
getCustomRangeEnding,
getCustomRangeStarting,
} from '@devtanc/daterange'
getCalendarRange('day')
getCalendarRange('day', 2)
getCalendarRange('month', 0, new Date(2017, 2, 12))
getCalendarRange('month', 1, new Date(2017, 2, 12))
getCalendarRangeStarting(new Date(2018, 0, 1), 5, 'days')
getCustomRangeEnding(new Date(2018, 0, 1), 5, 'days')