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

seconds-since-midnight

v1.0.6

Published

A super simple library for converting seconds since midnight to hours-minutes-seconds-am/pm and back

Downloads

4

Readme

seconds-since-midnight

A super simple library for converting seconds since midnight to hours-minutes-seconds-am/pm and back.

Seconds since midnight can be a convenient way to store a time of day (without a date) but there isn't much support for handling these values the way there is for date and time objects, like Date() and moment.js.

So this tiny zero-dependancy library will help you do conversions like

toSeconds('03', '15', 'AM')
// 11700
toReadableTime(50600)
// { hours: '2', minutes: '05', meridian: 'PM' }

Yep, that's all it does.

npm install seconds-since-midnight --save
import { toSeconds, toReadableTime } from 'seconds-since-midnight'
// or const { toSeconds, toReadableTime } = require('seconds-since-midnight')

// supports strings or numbers for hours and minutes and any capitalization for AM/PM
toSeconds( 2, '05', 'pm' )
// 50700

// supports negative values to handle wrapping back around when incrementing/decrementing
toSeconds( -1, '00', 'AM' ) === toSeconds( 11, '00', 'PM' )
// true

// and values greater than 12 hours/60 minutes to support wrapping the other way
toSeconds( '13', '05', 'AM' ) === toSeconds( 1, '05', 'PM' )
// true

// going the other direction it returns an object
toReadableTime( 11700 )
// { hours: '3', minutes: '15', meridian: 'AM' }


// it will roll with it if it recieves a negative value or a value greater than one day
toReadableTime( 91800 ) // 25.5 hours
// { hours: '1', minutes: '30', meridian: 'AM' }

toReadableTime( -3600 ) // -1 hour
// { hours: '11', minutes: '00', meridian: 'PM' }