Skip to content

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

License

Notifications You must be signed in to change notification settings

v-sayapin/delta-year

Repository files navigation

Δ 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.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published