delta-year
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

Δ Y E A R

The function returns the difference of two dates in the form of a decimal year

license

Installation

Using npm:

$ npm install delta-year

Using yarn:

$ yarn add delta-year

Using pnpm:

$ pnpm add delta-year

Usage

Once the package is installed, you can import the library using import approach:

import getDeltaYear from 'delta-year';

You can also import type DateTime in TypeScript modules:

import getDeltaYear, { type DataTime } from 'delta-year';

Use the getDeltaYear function to compare two dates:

getDeltaYear('2020.01.01', new Date('2022.07.01'));
// output: 2.4952120383036935

⚠️ WARNING: The dt passed to the first argument must be less than or equal to the dt passed to the second argument:

getDeltaYear('2022.01.01', '2020.01.01');
// output: Uncaught Error: The dtStart must be less than or equal to the dtEnd: 2022.01.01 > 2020.01.01

License

MIT.

Package Sidebar

Install

npm i delta-year

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

5.04 kB

Total Files

5

Last publish

Collaborators

  • vladxlav