GithubHelp home page GithubHelp logo

simple-date-utilites's Introduction

Simple Date Utility

This library provides a comprehensive set of functions to manage dates effectively in your JavaScript/TypeScript applications. The main objective of this library is to make date handling tasks, like date formatting, date parsing, calculating differences between dates, and other date manipulations easier and more efficient.

Features

  1. Date Validation: The isDate() function can be used to check if a given variable is a date object.

  2. Date Formatting: The formatDate() function allows you to format dates into a variety of formats.

  3. String to Date Conversion: The convertToDateObj() function allows you to convert a date string into a date object based on the provided format.

  4. MySQL String to Date Conversion: The mysqlStrToDate() function converts a MySQL formatted date string into a JavaScript date object.

  5. Date Difference Calculation: The calculateDateDifference() function calculates the difference between two dates in days, hours, minutes, and seconds. The differenceInMonths() function calculates the difference in months between two dates and the differenceInDays() function calculates the difference in days.

  6. Date Cloning and Manipulation: The cloneDate() function creates a clone of a provided date object with the ability to modify specific date parts like year, month, day, hour, and minute. The addDays() function creates a new date by adding a specified number of days to a provided date.

  7. Time Setting: The setTime() function allows you to set the time of a date object based on a provided string.

  8. Date Comparison: The isPastDate() function checks if a provided date is in the past. The isInRange() function checks if a date falls within a specified range.

Installation

To install this library, you need to have Node.js and npm installed on your machine. Use the following command to install the library:

npm install simple-date-utilities

(Note: Replace simple-date-utilities with the actual name of this library.)

Usage

Once the library is installed, you can import it into your JavaScript/TypeScript file like so:

import * as dateUtil from 'simple-date-utilities';

And then use any of the functions from this library in your code. Here is an example of using the formatDate() function:

let date = new Date();
let formattedDate = dateUtil.formatDate(date, "WD_DD_MMM_YYYY");
console.log(formattedDate); // Outputs the date in the format 'Mon 21 Jun 2023'

For detailed usage instructions of each function, please refer to the API documentation section of this README or the code comments in the library itself.

Contribution

We welcome any contributions to improve this library. Please fork this repository, make your changes and submit a pull request.

License

This library is licensed under the MIT License.

simple-date-utilites's People

Contributors

jonathandsouza avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.