This package was developed to manipulate dates in the USA and Brazilian format.
Instructions:
First of all, create a package.json:
npm init -y
Install the package:
npm i date_operations_manipulator2
Run the following command:
npm install @types/node --save-dev
NOTE: You can just copy and paste the following codes to see how each one works.
After this, you can import the package into your project
const dateManipulator = require('date_operations_manipulator2');
Now you can use the series of available methods in the package. Available operations:
DateManipulator parameters
Note: This package does not use parameters, it contains a property called
"parameters" which is used to pass the values to the class.
usa: boolean //true for USA date format
brazil: boolean //true for Brazilian date format
fullDate: string //It receives a date in a string format
sumYear: number //It receives an integer representing how many years will be added into the date
sumMonth: number //It receives an integer representing how many months will be added into the date
sumDay: number //It receives an integer representing how many days will be added into the date
let usa = new dateManipulator.DateManipulator(); It creates an object to get the USA date format
usa.parameters.usa = true;
let currentUSAdate = usa.getNewDate();
let br = new dateManipulator.DateManipulator(); It creates an object to get the Brazilian date format
br.parameters.brazil = true;
let currentBrDate = br.getNewDate();
usa.parameters.fullDate = currentUSAdate; It adds three more years in the USA date format
usa.parameters.sumYear = 3;
console.log(`3 more years: ${usa.addYearsToDate()}`);
br.parameters.brazil = true; It adds one more year at Brazilian date format
br.parameters.fullDate = currentBrDate;
br.parameters.sumYear = 1;
console.log(`3 more years: ${br.addYearsToDate()}`);
usa.parameters.usa = true; It adds 5 days in the USA date format
usa.parameters.fullDate = currentUSAdate;
usa.parameters.sumDay = 5;
console.log(`5 more days: ${usa.addDaysToDate()}`);
br.parameters.brazil = true; It adds 5 days at Brazilian date format:
br.parameters.fullDate = currentBrDate;
br.parameters.sumDay = 5;
console.log(`5 more days: ${br.addDaysToDate()}`);
usa.parameters.usa = true; It adds 5 months in the USA date format
usa.parameters.sumMonth = 5;
usa.parameters.fullDate = currentUSAdate;
console.log(`5 more months: ${usa.addMonthsToDate()}`);
br.parameters.brazil = true; It adds 5 months when at Brazilian date format
br.parameters.sumMonth = 5;
br.parameters.fullDate = currentBrDate;
console.log(`5 more months: ${br.addMonthsToDate()}`);