The function returns the difference of two dates in the form of a decimal year
Using npm:
$ npm install delta-year
Using yarn:
$ yarn add delta-year
Using pnpm:
$ pnpm add delta-year
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
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
MIT.