# cc-time-ago

> A lightweight time-ago formatter with i18n support, future dates, and real-time updates

Latest version **3.0.2** (published 2025-04-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install cc-time-ago
pnpm add cc-time-ago
yarn add cc-time-ago
bun add cc-time-ago
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.2 |
| Published | 2025-04-03 |
| First published | 2022-01-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=14.0.0 |
| Dependencies | 0 |
| Unpacked size | 24.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Fidelis Musamba |
| Maintainers | devfidelis |
| Keywords | time, time ago, i18n, date formatting, relative time |

## Links

- npm: https://www.npmjs.com/package/cc-time-ago
- Repository: https://github.com/DevFidelis/time-ago-module
- Homepage: https://github.com/DevFidelis/time-ago-module#readme
- Issues: https://github.com/DevFidelis/time-ago-module/issues
- npm.io page: https://npm.io/package/cc-time-ago

## Alternatives

- [@js-joda/timezone](https://npm.io/package/@js-joda/timezone.md) — 383.4K weekly downloads
- [chartjs-adapter-moment](https://npm.io/package/chartjs-adapter-moment.md) — 210.8K weekly downloads
- [strftime](https://npm.io/package/strftime.md) — 171.2K weekly downloads
- [vue-flatpickr-component](https://npm.io/package/vue-flatpickr-component.md) — 115.8K weekly downloads
- [timepicker](https://npm.io/package/timepicker.md) — 51.0K weekly downloads

## Recent versions

- 3.0.2 (latest) — 2025-04-03
- 3.0.1 — 2025-04-03
- 3.0.0 — 2025-04-03
- 2.1.0 — 2024-07-13
- 2.0.3 — 2023-12-02
- 2.0.2 — 2023-12-01
- 2.0.1 — 2023-12-01
- 2.0.0 — 2023-12-01
- 1.0.4 — 2023-01-02
- 1.0.3 — 2022-01-29
- 1.0.2 — 2022-01-29
- 1.0.1 — 2022-01-29
- 1.0.0 — 2022-01-29

## README

# TinnovAce Time Module

[![npm version](https://badge.fury.io/js/cc-time-ago.svg)](https://www.npmjs.com/package/cc-time-ago)
![GitHub](https://img.shields.io/github/license/DevFidelis/time-ago-module)
[![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-blue)](https://www.typescriptlang.org)

A lightweight time formatter with i18n support, future dates, real-time updates, and TypeScript types. Formats dates as "just now", "1h ago", or "in 5 minutes".

## Features

- **14 Built-in Languages** + Custom Language Support
- **Future Date Formatting** ("in 5 minutes")
- **Real-Time Auto Updates** (Perfect for UIs)
- **Customizable Thresholds** (Control when units change)
- **TypeScript Ready** with Full Type Definitions
- **Compact Mode** ("1h" instead of "1 hour ago")
- **Smart Caching** for High Performance

## Installation

```console
npm install cc-time-ago
```

## Basic Usage

```js
const { timeAgo } = require('cc-time-ago');

// Basic usage
console.log(timeAgo(Date.now() - 300000)); // "5 minutes ago"

// With options
console.log(timeAgo(Date.now() + 3600000, { 
  language: 'es',
  allowFuture: true
})); // "en 1 hora"
```

## Advanced Usage

### Custom Thresholds

```js
timeAgo(date, {
  thresholds: {
    seconds: 120,  // Show seconds up to 2 minutes
    minutes: 3600  // Show minutes up to 1 hour
  }
});
```

### Real-Time Updates (React/Vue/etc)

```js
const { autoUpdate } = require('cc-time-ago');

const { stop } = autoUpdate(someDate, (formattedTime) => {
  console.log(formattedTime); // Updates every 30s
});

// Call stop() when done
```

### Add Custom Languages

```js
const { addLanguage } = require('cc-time-ago');

addLanguage('ko', {
  justNow: '방금',
  minuteAgo: '1분 전',
  // ...
});
```

## Options

- **`language`** (string, default: *Auto-detected*)  
  - Language code (e.g., 'es', 'fr')  

- **`compact`** (boolean, default: *false*)  
  - Compact format ("1h" vs "1 hour ago")  

- **`allowFuture`** (boolean, default: *false*)  
  - Format future dates ("in 5 minutes")  

- **`thresholds`** (object, default: *[See below](#default-thresholds)*)  
  - Custom unit thresholds  

### Default Thresholds

```js
{
  seconds: 60,     // Show seconds until 1 minute
  minutes: 3600,   // Show minutes until 1 hour
  hours: 86400,    // Show hours until 1 day
  days: 604800,    // Show days until 1 week
  weeks: 2600640,  // Show weeks until ~1 month
  months: 31207680 // Show months until 1 year
}
```

## Supported Languages

- `en` - English  
- `es` - Spanish  
- `fr` - French  
- `de` - German  
- `it` - Italian  
- `ar` - Arabic  
- `tr` - Turkish  
- `nl` - Dutch  
- `ja` - Japanese  
- `zh` - Chinese  
- `ru` - Russian  
- `pt` - Portuguese  
- `hi` - Hindi  

**Missing a language?**  

[Add it yourself](#contributing) or [request it](https://github.com/DevFidelis/time-ago-module/issues)!

## Contributing

1\. Fork the repository

2\. Add/Update languages in `languages.js`

3\. Write tests for new features

4\. Submit a PR

## License

This project is licensed under the MIT License - see the [LICENSE](https://github.com/DevFidelis/time-ago-module/blob/master/LICENSE) file for details.

**Time Module © 2022 - 2025, a product of [TinnovAce](https://tinnovace.tech).**

---
_Source: https://npm.io/package/cc-time-ago · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
