date-range-compressor

Reduces a date range to full years, full months, and days between two dates.

Usage no npm install needed!

<script type="module">
  import dateRangeCompressor from 'https://cdn.skypack.dev/date-range-compressor';
</script>

README

date-range-compressor

Reduces a date range to full years, full months, and days between two dates.

Installation

Using npm, npm i date-range-compressor.

Using yarn, yarn add date-range-compressor.

Usage

Using import

import { compressDateRange } from 'date-range-compressor';

const compressedRange = compressDateRange('20191230', '20210203');

// compressedRange is {years: ['2020'], months: ['202101'], days: ['20191230', '20191231', '20210201', '20210202', '20210203']}

In a CommonJS environment

const { compressDateRange } = require('date-range-compressor');

const compressedRange = compressDateRange('20191230', '20210203');

// compressedRange is {years: ['2020'], months: ['202101'], days: ['20191230', '20191231', '20210201', '20210202', '20210203']}

Table of contents

Functions

Functions

compressDateRange

compressDateRange(start: string, end: string): CompressedDateRange

Compresses a date range between two days expressed as string date expressions

export

link https://day.js.org/docs/en/parse/string-format Possible date formats

Parameters:

Name Type Description
start string Starting day as any valid date string
end string End day as any valid date string

Returns: CompressedDateRange

The full years, full months and days included in that range

Defined in: index.ts:21