1.0.1 • Published 3 years ago

simple-dates v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

Simple Dates

Simple, lightweight javascript library for manipulating dates

Build Status

Simple Dates is lightweight & typed date manipulator

Features

  • Getting UTC date
  • Ability to add "x" amount of hours, minutes and seconds to dates
  • Comparing dates
  • Formatting dates (TODO)
  • Locale support (TODO)

Installation

npm install simple-dates

or

yarn add simple-dates

Usage

Getting UTC Date

import {getUTCDate} from "simple-dates"; 
const date = getUTCDate(); // if epoch needed getUTCDate(true);

Adding Hours To Date

import {addHours} from "simple-dates"; 
const date = addHours(1); // hours: number, date = new Date(), utc = false, epoch = false

Adding Minutes To Date

import {addMinutes} from "simple-dates"; 
const date = addMinutes(30); // mins: number, date = new Date(), utc = false, epoch = false

Adding Seconds To Date

import {addSeconds} from "simple-dates"; 
const date = addSeconds(20); // secs: number, date = new Date(), utc = false, epoch = false

Note: if epoch is true utc parameter is ignored

Comparing Dates

import {isLater} from "simple-dates";

const date1 = new Date();
const date2 = new Date();
date2.setMinutes(date2.getMinutes() + 30);

console.log(isLater(date1, date2)); // returns false

## License

ISC