# tiny-human-time

> A tiny module for human readable timespans.

Latest version **1.2.0** (published 2016-03-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install tiny-human-time
pnpm add tiny-human-time
yarn add tiny-human-time
bun add tiny-human-time
```

## Health

**Score 23/100 (F)** — status: abandoned.

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2016-03-06 |
| First published | 2016-03-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/tiny-human-time) |
| Module format | CommonJS |
| Node | >=4 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Dana Silver |
| Maintainers | danasilver |
| Keywords | tiny, time, humanize, human, timespan, timedelta |

## Links

- npm: https://www.npmjs.com/package/tiny-human-time
- Repository: https://github.com/danasilver/tiny-human-time
- Homepage: https://github.com/danasilver/tiny-human-time#readme
- Issues: https://github.com/danasilver/tiny-human-time/issues
- npm.io page: https://npm.io/package/tiny-human-time

## 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

- 1.2.0 (latest) — 2016-03-06
- 1.1.0 — 2016-03-06
- 1.0.0 — 2016-03-05

## README

<h3 align="center">
  <img src="http://i.giphy.com/DluPT7dZ0uXg4.gif">
</h3>

<h3 align="center">Tiny Human Time</h3>

<p align="center">
  A tiny module for human readable timespans.
</p>

[![Build Status](https://travis-ci.org/danasilver/tiny-human-time.svg?branch=master)](https://travis-ci.org/danasilver/tiny-human-time)

## API

### `humanize(t1, t2 [, units])`

What you get when you `require('tiny-human-time')`.

`t1` and `t2` are instances of `Date` or integers whose value relative to one
another is given in milliseconds. Their order doesn't matter.

If `t2` is not given, `t1` alone will be used as the timespan relative to 0.

Either argument can be an array of the form `[seconds, nanoseconds]`, like
that produced by
[process.hrtime()](https://nodejs.org/api/process.html#process_process_hrtime).

An optional last argument, `units` has possible values `short` and `long`,
defaulting to `long`. `units` can be given as the last argument even if
`t2` is not given.

Returns the converted value and the greatest matching unit
without going over. For example, `23 hours` will be followed by `1 day`.

### `humanize.short(t1, t2)`

A convenience method to use `short` units. The possible arguments for `t1` and
`t2` are the same as `humanize`.

## Supports:

 - nanoseconds
 - microseconds
 - milliseconds
 - seconds
 - minutes
 - hours
 - days
 - weeks
 - years

## Usage

```js
const humanize = require('tiny-human-time');

const now = new Date(2016, 3, 5);
const later = new Date(2016, 3, 6);

humanize(now, later);
// => 1 day
```

```js
const humanize = require('tiny-human-time');

const start = process.hrtime()
// and then a miracle occurs
const elapsed = process.hrtime(start)

humanize(elapsed)
// => 23 microseconds
```

```js
const humanize = require('tiny-human-time').short;

humanize(1)
// => 1ms
```

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