From 7c550a7d249a0047fc3360c9ad302733b78146de Mon Sep 17 00:00:00 2001 From: Farhan Reza Date: Tue, 5 Mar 2024 21:11:12 +0530 Subject: [PATCH] Update README.md to integrate diff as Date Object method Update README.md to integrate diff as Date Object method on importing --- README.md | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3d4d13df..6605948e 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,17 @@ const DatesYMD = require('diff-ymd-package'); // can use any if authenticated ``` +**`OR` for version `3.1.0` and `above`** + +**Can use simplified function `diff` as Global Date Object method** + +```javascript +//require('@farhan7reza7/diff-ymd-package'); //or + +require('diff-ymd-package'); // can use any if authenticated + +``` + ### `Create an instance:` ```javascript @@ -93,8 +104,25 @@ const Formatter = new DatesYMD(date1, date2); const date1 = '2022-01-01'; const date2 = '2023-12-31'; -const Formatter = DatesYMD.diffDates(date1, date2); // can use any +const Formatter = DatesYMD.diffDates(date1, date2); +``` + +**`OR` for version `3.1.0` and `above`** + +**Can use simplified function `diff` as Global Date Object method** + +```javascript +const date1 = '2022-01-01'; +const date2 = '2023-12-31'; + +const DateInstance = new Date(date1); // create Global Date instance + +const Formatter = DateInstance.diff(date2); //create an instance to `calculates the difference` between `Date instance` and the `date passed to it` + ``` +**Note:** For `diff` as `Global Date method`, `only one date(the date to be subtracted from/to Global Date instance)` passed to `diff method` + +**`diff` method create an instance of DatesYMD to `calculates the difference` between `Date instance` and the `date passed to it`** **Note:** For CDN based, only **DatesYMD** constructor name creates an instance, and can use diffDates as well, but only using global **DatesYMD** like **DatesYMD.diffDates(...)**