A library for date and time manipulation
npm install nowts
sh
npm install nowts
`
Usage
To use NowTS, you need to import and extend the desired plugins:
`javascript
import NowTS from 'nowts';
import formatDate from 'nowts/plugins/formatDate';
import parseDate from 'nowts/plugins/parseDate';
NowTS.extend(formatDate);
NowTS.extend(parseDate);
const formattedDate = NowTS.formatDate(new Date(), 'YYYY-MM-DD');
const parsedDate = NowTS.parseDate('2024-01-01', 'YYYY-MM-DD');
console.log(formattedDate); // Outputs formatted date
console.log(parsedDate); // Outputs parsed date object
`
API
$3
Formats a date object into a string according to the specified format.
$3
Parses a date string into a Date object according to the specified format and timezone.
$3
Adds a specified number of days to a date object.
$3
Subtracts a specified number of days from a date object.
$3
Returns the difference in days between two dates.
$3
Converts a date object to an ISO string.
$3
Returns a new date object set to the start of the month of the provided date.
$3
Returns a new date object set to the end of the month of the provided date.
$3
Formats the current time in 'HH:mm:ss' format.
$3
Adds a specified number of hours to a date object.
$3
Subtracts a specified number of hours from a date object.
$3
Parses a time string into a Date object.
$3
Checks if a given year is a leap year.
$3
Checks if a given date is a weekday.
$3
It compares two days and returns whether they are the same or not.
$3
Check business days excluding holidays
Development
To set up the development environment, clone the repository and install the dependencies:
`sh
git clone https://github.com/lnpotter/NowTS.git
cd NowTS
npm install
`
$3
To build the library, run:
`sh
npm run build
`
$3
To run the tests, use:
`sh
npm run test
``