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

minutes-to-max-human-time

v1.0.0

Published

Takes minutes and returns the maximum whole human readable equivalent in minutes, hours, days or weeks

Downloads

14

Readme

minutes-to-max-human-time

Build Status via Travis CI Coverage Status

Takes minutes and returns the maximum whole human readable equivalent in minutes, hours, days or weeks. Mimics Google Calendar online appointments for setting reminders (notifications).

For example:

  • 50 minutes returns 50 minutes
  • 60 minutes returns 1 hour
  • 70 minutes returns 70 minutes
  • 1440 minutes returns 1 day
  • 1441 minutes returns 1441 minutes
  • 100800 minutes returns 1 week

Install options:

  • npm install minutes-to-max-human-time
  • bower install minutes-to-max-human-time

###Example:

var m2MaxHT = require('minutes-to-max-human-time');

m2MaxHT.getMax(0);    // { timeQty: 0, timePeriod: 'minutes' }

m2MaxHT.getMax(59);   // { timeQty: 59, timePeriod: 'minutes' }

m2MaxHT.getMax(60);   // { timeQty: 1, timePeriod: 'hours' }

m2MaxHT.getMax(61);   // { timeQty: 61, timePeriod: 'minutes' }

m2MaxHT.getMax(60*23);  // { timeQty: 23, timePeriod: 'hours' }

m2MaxHT.getMax(60*24);  // { timeQty: 1, timePeriod: 'days' }

m2MaxHT.getMax(60*25);  // { timeQty: 25, timePeriod: 'hours' }

m2MaxHT.getMax(60*24*6); // { timeQty: 6, timePeriod: 'days' }

m2MaxHT.getMax(60*24*7+1);
// { timeQty: 10081, timePeriod: 'minutes' }

m2MaxHT.getMax(60*24*7);  // { timeQty: 1, timePeriod: 'weeks' }

m2MaxHT.getMax(60*24*8);  // { timeQty: 8, timePeriod: 'days' }

minutes-to-max-human-time has 2 functions: getMax and getMinutes.

###getMax(minutes, objectToUpdate, maxMinutes) Returns an object with these 2 parameters:

  • timeQty: integer,
  • timePeriod: string of 'minutes', 'hours', 'days', or 'weeks'

'weeks' is the maximum whole human readable equivalent given minutes.

####minutes

  • integer, required

####objectToUpdate

  • object literal, optional.
  • If passed in objectToUpdate will be updated with timeQty and timePeriod parameters. If not included, a new object is returned.

example:

var m2MaxHT = require('minutes-to-max-human-time');
var myObj = {method: 'email', minutes:60};
m2MaxHT.getMax(myObj.minutes, myObj);
console.log(myObj);
// { method: 'email', minutes: 60, timeQty: 1, timePeriod: 'hours' }

####maxMinutes

  • integer, optional, default = 40320 (4 weeks);
  • If passed in will reset minutes parameter to maxMinutes if minutes is > maxMinutes

example:

m2MaxHT.getMax(85, {}, 80);
// { timeQty: 80, timePeriod: 'minutes' }  // minutes was set to 80 from 85

###getMinutes(object) Returns the number of minutes given an object with parameters timeQty and timePeriod. ####object

  • object literal, required.
  • must be an object with parameters timeQty and timePeriod where timeQty is an integer and timePeriod is a string of 'minutes','hours','days' or 'weeks'.

example:

var m2MaxHT = require('minutes-to-max-human-time');

var myObj = {timeQty: 1, timePeriod: 'hours' };
var minutes = m2MaxHT.getMinutes(myObj);
console.log(minutes);
// 60