npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

date-dealer

v3.3.2

Published

Date and time processing library.

Downloads

145

Readme

(All what you need about date and time) we still have long road to achieve this, but we work on it. any contribution or suggestion will be highly appreciated.

Installation

npm i date-dealer

Usage

const dateDealer = require("date-dealer")

// parse to date
const  dateObject = dateDealer.dateOf('2019-03-24');
console.log(dateObject);

// format date string or object
const  formattedDate = dateDealer.doFormat('2019-03-24 12:30:40', 'dd-mm-yy h:MM:ss');
console.log(formattedDate);
/*
available formats:
[
  'ddd mmm dd yyyy HH:MM:ss',
  'm/d/yy',
  'mmm d, yyyy',
  'mmmm d, yyyy',
  'dddd, mmmm d, yyyy',
  "yyyy-mm-dd'T'HH:MM:sso",
  "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'",
  'ddd, dd mmm yyyy HH:MM:ss Z',
  'h:MM TT',
  'h:MM:ss TT',
  'h:MM:ss TT Z',
  'yyyy-mm-dd',
  'HH:MM:ss',
  'yyyy-mm-dd HH:MM:ss',
  'yyyy-mm-dd'
 ]
*/

// get dates array started from specific date
const dates = dateDealer.getDatesArray('2019-10-10', 12, false));
console.log(dates);
// similar getDatesAfter and getDatesBefore, dateDealer.getDatesBetween('2019-01-10', '2019-01-21')

const time = dateDealer.addMinutes('13:50', 20);
console.log(time); // 14:10

// return day index [Mon,Tue,...,Sun] -> [0,1,...,6]
const dayIndex = dateDealer.getDayIndex('2019-01-10');
console.log(dayIndex);

const isoString = ISOStringOf('2019-01-10 12:30:40'); // the date as object or string
console.log(isoString); // iso string of the date

const timeStamp = dateDealer.timeStampOf('2019-01-10 12:30:40');
console.log(timeStamp); // timestamp in milliseconds


// check if the given date is weekend (Saturday or Sunday)
const isWeekend = dateDealer.isWeekEnd('2019-12-21');
console.log(isWeekend); // true

const thisMoment = dateDealer.atThisMoment('HH:MM:ss');

console.log(thisMoment);
//similar 
 dateDealer.beforeYesterday('yyyy-mm-dd'),
 dateDealer.yesterday('yyyy-mm-dd'),
 dateDealer.tomorrow('yyyy-mm-dd'),
 dateDealer.afterTomorrow('yyyy-mm-dd'),
 dateDealer.mondayThisWeek(), 
 dateDealer.tuesdayThisWeek(), 
 dateDealer.wednesdayThisWeek(), 
 dateDealer.thursdayThisWeek(), 
 dateDealer.fridayThisWeek(), 
 dateDealer.saturdayThisWeek(), 
 dateDealer.sundayThisWeek(), 
 const dateObject = dateDealer.dateObjectOf(dateDealer.atThisMoment());
//accept the date either as string or an object and return date Object which has the following properties
   .plusYears(x)
   .plusMonths(x)
   .plusDays(x)
   .plusHours(x)
   .plusMinutes(x)
   .plusSeconds(x)
   .minusYears(x)
   .minusMonths(x)
   .minusDays(x)
   .minusHours(x)
   .minusMinutes(x)
   .minusSeconds(x)
// at the end to get usable date in any format
   .get('yyyy-mm-dd HH:MM:ss') // the default formt is 'yyyy-mm-dd HH:MM:ss'

Calculate age:

const age = dateDealer.calculateAge('1984-06-19');
//{ years: 36, months: 6, days: 18 }

Time between:

const timeBetween = dateDealer.timeBetween('2021-04-23 21:37:30', '2021-05-20 22:40:20');
//{ days: 27, hours: 1, minutes: 2, seconds: 50 }

//similar 
dateDealer.timeSince('2021-04-23 21:37:30')
dateDealer.timeUntil('2022-04-23 21:37:30')

License

(MIT License)

Copyright © 2019-2022 Jafar Jabr

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.