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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@libchrono/time

v1.2.2

Published

Small library to handle time format conversion.

Readme

🕒 @libchrono/time

npm version GitHub license

⏳ Simple Time Format Converter

@libchrono/time is a lightweight and zero-dependency JavaScript library that helps you effortlessly:

✅ Convert 24-hour (military) time to 12-hour (meridiem) time

✅ Convert 12-hour (meridiem) time to 24-hour (military) time

✅ Validate if a string is a valid military or civilian time format

✅ Extract each component of time string in both formats

📦 Installation

To use @libchrono/time in your project, install it via npm:

npm install @libchrono/time

or yarn:

yarn add @libchrono/time
const { convertMeridiemToMilitary } = require('@libchrono/time');
// or using ES Modules
import { convertMeridiemToMilitary } from '@libchrono/time';

console.log(convertMeridiemToMilitary('10:00 AM')); // result: 10:00

🔧 API Reference

Convert 24-hour time to 12-hour time

console.log(convertMilitaryToMeridiem('23:45')); // Output: "11:45 PM"
console.log(convertMilitaryToMeridiem('09:30')); // Output: "9:30 AM"

Convert 12-hour time to 24-hour time

console.log(convertMeridiemToMilitary('11:45 PM')); // Output: "23:45"
console.log(convertMeridiemToMilitary('9:30 AM')); // Output: "09:30"

Validate if a string is in military (24-hour) time format

console.log(isMilitaryFormat('23:45')); // Output: true
console.log(isMilitaryFormat('11:45 PM')); // Output: false
console.log(isMilitaryFormat('25:30')); // Output: false (invalid time)

Validate if a string is in civilian (12-hour) time format

console.log(isMeridiemFormat('11:45 PM')); // Output: true
console.log(isMeridiemFormat('23:45')); // Output: false
console.log(isMeridiemFormat('13:30 PM')); // Output: false (invalid time)

Extract components of the time string

console.log(getMeridiemComponents('11:45 PM')); // Output: { hour: 11, minute: 45, period: 'PM' }
console.log(getMilitaryComponents('23:45')); // Output: { hour: 23, minute: 45 }

Get times labels in military format

console.log(getMilitaryTimes('00:00', '23:59', 10)) // Output: ['00:00', '00:10', '00:20', ... '23:50']
console.log(getMeridiemTimes('08:30 AM', '12:00 PM', 30)) // Output: ['08:30 AM', '09:00 AM', '09:30 AM', ..., '12:00 PM']

Calculate seconds in time window

calculateMilitaryTimeWindowInSec('08:00', '12:00'); // 14400
calculateMeridiemTimeWindowInSec('8:00 AM', '12:00 PM'); // 14400

Full documentation

🛠️ Why Use @libchrono/time

✅ Zero dependencies – lightweight and efficient.

✅ Simple API – minimal, intuitive functions.

✅ Accurate conversions & validations – ensures correctness.

✅ Fully tested – reliable with unit tests.