chronokit
v1.0.13
Published
ChronoKit is a powerful and flexible date/time manipulation library that makes it easy to perform common tasks such as converting between time zones, calculating time difference, and parsing date/time strings. With a simple intuitive API, ChronoKit offers
Downloads
46
Maintainers
Readme
ChronoKit
ChronoKit is a powerful and flexible date/time manipulation library for Node.js. With an intuitive API, ChronoKit makes it easy to perform common tasks such as converting between time zones, calculating time differences, and parsing date/time strings. Whether you're building a web app, working with time-based data, or just need to handle dates and times in your code, ChronoKit has you covered.
Date/Time Manipulation Library
A library that provides utility function with dates and time, including coverting between time zone, calculating time diference, and parsing date/time strings. This library is build for Node.js and can be used in any Node.js project.
Installation
To install the library, use the following command:
npm i chronokit
Usage
To use the library in your project, simply require it and start using the function:
import {convertTimeZone, convertDateTime, getTimeZoneOffSet} from 'chronokit';
const convertedTimeZone = convertTimeZone('2023-02-23T14:55:00Z', 'GMT', 'Australia/Darwin');
const convertedDateTime = convertDateTime('2023-02-23T23:35:00', 'Asia/Colombo', 'Europe/London');
const timeZoneOffSet = getTimeZoneOffSet('Asia/Colombo', 'Europe/London');
const month = performDateArithmetic(currentDate, { duration: 5, unit: 'month', operation: 'subtract' });
API Reference
convertTimeZone(dateTime, fromZone, toZone)
convertDateTime(dateTime, fromTimeZone, toTimeZone)
getTimeZoneOffset(timezone1, timezone2)
performDateArithmetic(currentDate, { duration: number, unit: string, operation: string })
performDateArithmetic(currentDate, { duration: 2, unit: 'week', operation: 'add' });
console.log(`Current date: ${currentDate.format('YYYY-MM-DD')}`);
console.log(`Two weeks later: ${twoWeeksLater.format('YYYY-MM-DD')}`);
output:
Current date: 2023-02-25
Two weeks later: 2023-03-11