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 🙏

© 2025 – Pkg Stats / Ryan Hefner

colloquial-time

v0.1.1

Published

A lightweight library to express time in colloquial, human-friendly phrases for various languages.

Downloads

27

Readme

Colloquial Time 🕒

Making time human-friendly with natural, everyday expressions.

Why stick with "07:15" when you can say "quarter past seven" or "setengah delapan"? This library helps you express time the way people actually talk—casual, natural, and easy to understand.


What’s This About? 🤔

colloquial-time is a lightweight JavaScript library for formatting time into everyday, spoken expressions. It focuses on practicality and real-world use, steering away from overly formal or robotic language.

Features ✨

  • Localized Expressions: Supports multiple languages, from English to Indonesian, Japanese, Russian, and more.
  • Zero Dependencies: Simple and efficient—no external dependencies required.
  • Natural Style: Prioritizes spoken language for casual conversations.
  • Special Cases: Includes "midnight" and "noon" handling where relevant.
  • Customizable: Create or tweak configurations to fit specific languages or regional dialects.

Installation 🚀

Install via npm or yarn:

npm install colloquial-time

or

yarn add colloquial-time

Usage 💻

Get started in seconds:

const {colloquial, languages} = require('colloquial-time');

// English Example
console.log(colloquial(new Date(), languages.en)); // "quarter past seven in the morning"

// Indonesian Example
console.log(colloquial(new Date(), languages.id)); // "jam tujuh lewat seperempat pagi"

Supported Languages 🌍

  • 🇮🇩 Indonesian (Bahasa Indonesia)
  • 🇬🇧 English
  • 🇩🇪 German (Deutsch)
  • 🇷🇺 Russian (Русский)
  • 🇫🇷 French (Français)
  • 🇪🇸 Spanish (Español)
  • 🇯🇵 Japanese (日本語)
  • 🇨🇳 Chinese (中文)

Bonus Examples 🎉

While not a primary focus, the library also supports:

  • Balinese (Bahasa Bali)
  • Javanese (Bahasa Jawa)
  • Sundanese (Bahasa Sunda)

These examples highlight how the library can accommodate regional and underrepresented languages, showcasing its flexibility.


API 📚

colloquial(date: Date, langConfig: LanguageConfig): string

Parameters:

  • date: A JavaScript Date object or a date string.
  • langConfig: Language configuration object (e.g., languages.en).

Returns:

  • A human-readable, colloquial time expression.

Custom Language Configurations 🛠️

Add your own language or modify existing ones. Here’s an example configuration for English:

module.exports = {
  numbers: ['', 'one', 'two', 'three', ...],
  minutePrepositions: { 5: 'five', 10: 'ten', ... },
  halfHourPrepositions: { 15: 'quarter', 30: 'half' },
  timeOfDay: [
    [0, 11, 'in the morning'],
    [12, 17, 'in the afternoon'],
    [18, 23, 'in the evening']
  ],
  words: {
    timePrefix: '',
    hourSuffix: " o'clock",
    less: 'to',
    more: 'past',
  },
  format: {
    exactHour: '{hour}{hourSuffix} {timeOfDay}',
    pastMinutes: '{minutes} {more} {hour} {timeOfDay}',
    toMinutes: '{minutes} {less} {hour} {timeOfDay}',
  },
};

Why Colloquial? 🤷

This library isn’t just about showing time; it’s about making time relatable. Whether you're coding for chatbots, smart devices, or just having fun with time formats, colloquial-time keeps things friendly and easy to understand.


Limitations and Contributions ✋

  • Not Perfect Yet: While the library supports many languages, the phrasing may not always align perfectly with everyday local expressions. Contributions are welcome to refine this! 🌍
  • Got Feedback?: Found a better way to phrase time in your language? Share it! Let’s make this better together.
  • Add New Languages: Want to see your language represented? Feel free to submit a configuration for it! Even lesser-known or regional languages are more than welcome. 🗣️
  • Expand Features: Have ideas for improving functionality or making the library more flexible? Contributions for additional features or edge cases are encouraged. ✨

Your input helps us make this library truly relatable across diverse cultures and communities! 🙌

How to Contribute 🛠️

Want to help improve colloquial-time? Awesome! Here’s how you can pitch in:

  1. Fork the Repository: Start by forking this repo to your GitHub account.

  2. Clone Your Fork: Clone the forked repo to your local machine:

    git clone https://github.com/your-username/colloquial-time.git
  3. Create a Branch: Create a branch for your contribution:

    git checkout -b feature/new-language
  4. Make Your Changes: Add or update language configurations, improve phrasing, or suggest new features.

  5. Test Your Changes: Run the test suite to ensure everything works:

    yarn test

    Example Output:

    Running tests...
    ✓ Indonesian - Exact hour
    ✓ Indonesian - Quarter past
    ✓ Japanese - Half past
    ✓ French - Midnight
    ✅ All 63 tests passed!
  6. Commit Your Work: Write a meaningful commit message:

    git commit -m "Add support for Klingon language 🖖"
  7. Push Your Branch: Push the branch to your fork:

    git push origin feature/new-language
  8. Open a Pull Request: Go to the original repo and open a pull request. Be sure to include a clear description of what you’ve added or fixed.


License 📄

MIT. Feel free to use, share, and improve.


Author 🎨

Created with care by Agus Made. For feedback or inquiries, feel free to reach out via GitHub.


Examples in Action 🎬

const {colloquial, languages} = require('colloquial-time');

// Russian
console.log(colloquial(new Date('2024-11-16T07:15:00'), languages.ru)); // "четверть восьмого утра"

// Japanese
console.log(colloquial(new Date('2024-11-16T07:30:00'), languages.ja)); // "七時三十分 午前"

// French
console.log(colloquial(new Date('2024-11-16T07:45:00'), languages.fr)); // "huit heures moins le quart du matin"

Let’s make telling time fun again! 🕰️