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-and-time-utility

v1.1.0

Published

An application that assists users in navigating the complexities of dates and times.

Downloads

2

Readme

date-time-utility

This package consists of several functions that assists users in handling the complexities of dates and times.

Features:

  • Vanilla Javascript, no additional packages used.
  • Given a specific date, how many seconds, minutes, hours, days, weeks, months, or years away is it?
  • Given two specific dates, how many seconds, minutes, hours, days, weeks, months, or years away are they from each other?

Modules:

Users have the ability to use one of the following modules that give users the functions corresponding to the timespan of choice:

* seconds
* minutes
* hours
* days
* weeks
* months
* years

timespan.fromCurrentTime(date)

Takes a date and determines how many {timespans} away it is from right now.

var date = new Date();
     
date.setDate(date.getDate() + 365);

const seconds = dateTimeUtility.seconds.fromCurrentTime(date); //31536000
const minutes = dateTimeUtility.minutes.fromCurrentTime(date); //525600
const hours = dateTimeUtility.hours.fromCurrentTime(date); //8760
const days = dateTimeUtility.days.fromCurrentTime(date); //365
const weeks = dateTimeUtility.weeks.fromCurrentTime(date); //52
const months = dateTimeUtility.months.fromCurrentTime(date); //12
const years = dateTimeUtility.years.fromCurrentTime(date); //1

timespan.betweenDates(date1, date2)

Takes two dates and determines how many {timespans} away they are from each other

const date1 = new Date();

const date2 = new Date();

date1.setDate(date1.getDate() + 5);

date2.setDate(date2.getDate() + 370);

const seconds = dateTimeUtility.seconds.betweenDates(date1, date2) //31536000
const minutes = dateTimeUtility.minutes.betweenDates(date1, date2) //525600
const hours = dateTimeUtility.hours.betweenDates(date1, date2) //8760
const days = dateTimeUtility.days.betweenDates(date1, date2) //365
const weeks = dateTimeUtility.weeks.betweenDates(date1, date2) //52
const months = dateTimeUtility.months.betweenDates(date1, date2) //12
const years = dateTimeUtility.years.betweenDates(date1, date2) //1

Additionally, users have a module that allows them to determine datetimes that are a specified amount of time from the current time, for example they can determine the datetime x seconds, minutes, hours, ect. from right now.

* datetime

datetime.secondsFromNow(number)

Takes a number and determines what the datetime is that number of seconds from then

const seconds = dateTimeUtility.datetime.secondsFromNow(60); //60 seconds from right now

datetime.minutesFromNow(number)

Takes a number and determines what the datetime is that number of minutes from then

const minutes = dateTimeUtility.datetime.minutesFromNow(60); //60 minutes from right now

datetime.hoursFromNow(number)

Takes a number and determines what the datetime is that number of hours from then

const hours = dateTimeUtility.datetime.hoursFromNow(60); //60 hours from right now

datetime.daysFromNow(number)

Takes a number and determines what the datetime is that number of days from then

const days = dateTimeUtility.datetime.daysFromNow(60); //60 days from right now

datetime.weeksFromNow(number)

Takes a number and determines what the datetime is that number of weeks from then

const seconds = dateTimeUtility.datetime.weeksFromNow(60); //60 weeks from right now

datetime.monthsFromNow(number)

Takes a number and determines what the datetime is that number of months from then

const months = dateTimeUtility.datetime.monthsFromNow(60); //60 months from right now

datetime.yearsFromNow(number)

Takes a number and determines what the datetime is that number of years from then

const years = dateTimeUtility.datetime.yearsFromNow(60); //60 years from right now

Additionally, within the same module, users have a set of convenience functions that allow them to see the datetime tomorrow, next week, next month, next year, yesterday, last week, last month, and last year.

* datetime

datetime.thisTimeTomorrow()

Tells the user the datetime this time tomorrow.

const time = dateTimeUtility.datetime.thisTimeTomorrow(); //This time tomorrow

datetime.thisTimeNextWeek()

Tells the user the datetime this time next week.

const time = dateTimeUtility.datetime.thisTimeNextWeek(); //This time next week

datetime.thisTimeNextMonth()

Tells the user the datetime this time next month.

const time = dateTimeUtility.datetime.thisTimeNextMonth(); //This time next month

datetime.thisTimeNextYear()

Tells the user the datetime this time next year.

const time = dateTimeUtility.datetime.thisTimeNextYear(); //This time next year

datetime.thisTimeYesterday()

Tells the user the datetime this time yesterday.

const time = dateTimeUtility.datetime.thisTimeYesterday(); //This time yesterday

datetime.thisTimeLastWeek()

Tells the user the datetime this time last week.

const time = dateTimeUtility.datetime.thisTimeLastWeek(); //This time last week

datetime.thisTimeLastMonth()

Tells the user the datetime this time last month.

const time = dateTimeUtility.datetime.thisTimeLastMonth(); //This time last month

datetime.thisTimeLastYear()

Tells the user the datetime this time last year.

const time = dateTimeUtility.datetime.thisTimeLastYear(); //This time last year