date-snap
v1.0.1
Published
Date parser and formater
Downloads
2
Readme
Certainly! Here's a template for a README file for your package "date-snap":
date-snap
date-snap is a lightweight npm package that provides simple and intuitive date and time utilities for JavaScript applications. It aims to simplify common tasks related to parsing, formatting, and manipulating dates and times, making it easier for developers to work with date and time values in their projects.
Features
- Parsing: Parse date/time strings into JavaScript Date objects effortlessly.
- Formatting: Format JavaScript Date objects into custom date/time strings with ease.
- Manipulation: Perform operations like adding/subtracting days, months, years, etc., with simplicity.
- Comparison: Easily compare two date/time values with intuitive functions.
- Timezone Conversion: Convert between different timezones seamlessly.
- Duration Calculation: Calculate the duration between two date/time values effortlessly.
- Validation: Validate whether a given string is a valid date/time with ease.
Installation
You can install date-snap via npm:
npm install date-snap
Usage
const { parse, format, addDays, isSame, convertToTimeZone, durationBetween, isValid } = require('date-snap');
// Parsing
const date = parse('2024-04-02');
console.log(date);
// Formatting
const formattedDate = format(date, 'YYYY-MM-DD');
console.log(formattedDate);
// Manipulation
const newDate = addDays(date, 7);
console.log(newDate);
// Comparison
const isSameDate = isSame(date, newDate, 'day');
console.log(isSameDate);
// Timezone Conversion
const convertedDate = convertToTimeZone(date, 'America/New_York');
console.log(convertedDate);
// Duration Calculation
const duration = durationBetween(date, newDate);
console.log(duration);
// Validation
const isValidDate = isValid('2024-02-30', 'YYYY-MM-DD');
console.log(isValidDate);
Contribution
Contributions are welcome! If you have any ideas for improvements or new features, feel free to open an issue or submit a pull request on GitHub.
License
date-snap is licensed under the MIT License.