Documentation

1. Installation

Installing the package

To install the package you need to have Node installed on your computer and run npm -i vdate command in the terminal to initialize installation. After the package has been installed, import it by using import {VDate} from "vdate".

2. Usage

2.1 Usage

Using VDate is like using any other class since that's what VDate actually is - a class. There are two main ways of using VDate which are using the class methods to operate onto the selected date and the using of static method meant to work with external dates without creating objects.

2.2 Date management methods

.getDay() Returns the current day of the object.

.getMonth() Returns the current month of the object.

.getYear() Returns the current year of the object.

.setYear(year) Sets the year of the object.

.setMonth(month Sets the month of the object.

.setDay(day) Sets the day of the object.

.addYears(num) Adds inputed number of years to object's years.

.addMonths(num) Adds inputed number of months to object's months.

2.3 Date and time formats

.dmyDot() Returns the date with day first and a dot as a separator. Example: "5.4.2020.".

.dmyDash()Returns the date with day first and a dash as a separator. Example:"5-4-2020".

.dmyZeroDot()Returns the date with day first and a dot as a separator with the 0 before the number. Example: "05.04.2020.".

.dmyZeroDash()Returns the date with day first and a dash as a separator with the 0 before the number. Example: "05-04-2020".

.mdyDot() Returns the date with month first and a dot as a separator. Example: "4.5.2020.".

.mdyDash()Returns the date with month first and a dash as a separator. Example:"4-5-2020".

.mdyZeroDot()Returns the date with month first and a dot as a separator with the 0 before the number. Example: "04.05.2020.".

.mdyZeroDash()Returns the date with month first and a dash as a separator with the 0 before the number. Example: "04-05-2020".

.getTime() Returns the time of the object without seconds. "12:45"

.getFullTime() Returns the time of the object with seconds. "12:45:25"

2.4 Date functionalities

.getWeek() Returns the current week of the objects's date.

.dayOfTheYear() Returns the number of the day of the objects's date.

A static .dayOfTheYear(date) accepts the date and returns the day of the year of the selected date.

.getMonthName() Returns the name of the current month of the object.

.getMonthShort() Returns the first three letters of the current month of the object.

.getDayName() Returns the name of the current day of the object.

.getDayShort() Returns the first three letters of the current day of the object.

A static method .equal(date1,date2) takes in two dates and returns a boolean value based on whether or not the first date is after the second one.

.isLeapYear() Returns a boolean value based on whether or not the current year of the date of the object is a leap year.

To get the date in the standard Date() format, just access the .date property of the created object.

3. Contribution

Contribution

VDate is open source project and to contribute to it you just need to open an issue on GitHub and create a pull request. Repository is on this link. To contact the author, email to veljkocukic@gmail.com .