UNPKG

remaining-period-calculator

Version:

It calculates between the two periods

48 lines (45 loc) 1.71 kB
###### Remaining period calculator is calculates between the two periods => past or future # Install ``` npm install remaining-period-calculator --save ``` # Usage ```javascript var rpc = require("remaining-period-calculator"); ``` ```javascript var remaining = new rpc.remainingPeriodCalculator(/*option*/); // The example Date now is : 13/2/2021 console.log(remaining.remainingYears(2025)); // result: 4 Years console.log(remaining.remainingYears(2015)); // result: 6 Years console.log(remaining.remainingMonths(4,2023)); // result: 26 Month console.log(remaining.remainingMonths(4)); // result: 2 Month console.log(remaining.remainingDays(10,5,2019));// result: 633 Days console.log(remaining.remainingDays(10,5));// result: 87 Days console.log(remaining.remainingDays(10));// result: 3 Days ``` # Options Key | Type | Default --- | ---- | ------- day | Number | Current day month | Number | Current month year | Number | Current year timeZone | Number | 0 # Range Key | range --- | ----- day | (1 -- 31) month | (1 -- 12) timeZone | (-12 -- 12) # example ```js // Example change default date var remaining = new rpc.remainingPeriodCalculator({day:27,month:6,year:2009,timeZone:3}); // Past remaining console.log(remaining.remainingYears(1999)); // result: 10 Years console.log(remaining.remainingMonths(5,1999)); // result: 121 Month console.log(remaining.remainingDays(15,5,1999));// result: 3642 Days // Futur remaining console.log(remaining.remainingYears(2019)); // result: 10 Years console.log(remaining.remainingMonths(5,2019)); // result: 119 Month console.log(remaining.remainingDays(15,5,2019));// result: 3558 Days ```