date-range-checker
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

Date Range Checker

A utility library for comparing date ranges.

Table of Contents

Installation

npm install date-range-checker

Usage

import {
  isInRange,
  isStartDateInRange,
  isEndDateInRange,
  isStartDateAndEndDateInRange,
  isStartDateAndEndDateIncludeRange
} from 'date-range-checker';
// or
const  {
  isInRange,
  isStartDateInRange,
  isEndDateInRange,
  isStartDateAndEndDateInRange,
  isStartDateAndEndDateIncludeRange
} = require('date-range-checker');


const result = isInRange(
  { startDate: new Date('2022-01-01'), endDate: new Date('2023-12-31') },
  { startDate: new Date('2023-01-01'), endDate: new Date('2023-11-01') }
);
//=> true

Functions

Name Params Return Description
isInRange (referenceDateRange: DateRange, comparisonDateRange: DateRange) boolean Checks if the provided date range is within another date range.
isStartDateInRange (referenceDateRange: DateRange, comparisonDateRange: DateRange) boolean Checks if the start date of the reference range is within the comparison range.
isEndDateInRange (referenceDateRange: DateRange, comparisonDateRange: DateRange) boolean Checks if the end date of the reference range is within the comparison range.
isStartDateAndEndDateInRange (referenceDateRange: DateRange, comparisonDateRange: DateRange) boolean Checks if both start and end dates of the reference range are within the comparison range.
isStartDateAndEndDateIncludeRange (referenceDateRange: DateRange, comparisonDateRange: DateRange) boolean Checks if both start and end dates of the reference range include the comparison range.

Contributing

Contributions are welcome! Read contributing guide

License

This project is licensed under the MIT License.

Package Sidebar

Install

npm i date-range-checker

Weekly Downloads

15

Version

1.1.0

License

MIT

Unpacked Size

83.9 kB

Total Files

29

Last publish

Collaborators

  • hkc321