# time-format-utils

> Simple utilities for fast duration formatting

Latest version **1.0.3** (published 2015-03-09) · 0 weekly downloads

## Install

```sh
npm install time-format-utils
pnpm add time-format-utils
yarn add time-format-utils
bun add time-format-utils
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2015-03-09 |
| First published | 2015-03-05 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Pedro Tacla Yamada |
| Maintainers | toggl |

## Links

- npm: https://www.npmjs.com/package/time-format-utils
- npm.io page: https://npm.io/package/time-format-utils

## Recent versions

- 1.0.3 (latest) — 2015-03-09
- 1.0.2 — 2015-03-06
- 1.0.0 — 2015-03-05

## README

time-format-utils
=================
[![npm version](https://img.shields.io/npm/v/time-format-utils.svg)](https://npmjs.org/package/time-format-utils)
[![Build Status](https://travis-ci.org/toggl/time-format-utils.svg)](https://travis-ci.org/toggl/time-format-utils)
- - -
Simple utilities for fast duration formatting.

## Compatibility layer
All functions in the external API (all functions which aren't prefixed with
'_') are also exported with snake case names, in order to be compatible with
older versions of this module.

## External API
### secondsToExtHhmmss(t, type)

Formats an amount of seconds in the specified "duration format"

#### Params:

* **Number** *t* Amount in seconds
* **String** *type* One of 'improved', 'decimal' and 'classic'

#### Return:

* **String**

### secToHhmmImproved(seconds)

Pretty formats some amount of milliseconds in a span `duration` tag.

#### Params:

* **Number** *seconds*

#### Return:

* **String**

### millisecondsToHhmmss(ms)

Pretty formats some amount of milliseconds in "hh:mm:ss".

#### Params:

* **Number** *ms*

#### Return:

* **String**

### secToDecimalHours(secs)

Formats some amount of seconds in hours with two decimal cases ("hh.hh h").

#### Params:

* **Number** *secs*

#### Return:

* **String**

## Helper functions (aliases)
- `secondsToHhmm(secs)` is an alias to `baseSecondsToHhmm(secs, ':', ' h')`
- `secondsToSmallHhmm(secs)` is an alias to `baseSecondsToHhmm(secs, ':')`
- `secondsToPrettyHhmm(secs)` is an alias to `baseSecondsToHhmm(secs, ' h ', ' min')`

## Internal API
### _baseSecondsToHhmm(secs)

Formats some amount of seconds in "hh:mm" with a variable separator `sep` and
suffix `suffix`.

#### Params:

* **Number** *secs* The amount of seconds to format
* **String** *sep* A separator
* **String** *suffix* A suffix

#### Return:

* **String**

### _leftPad(val, size, ch)

Pads a value `val` to the left by `size` `ch` or `' '` characters.

#### Params:

* **Mixed** *val* The value to pad
* **Number** *size* The padding's size
* **String** *[ch=' ']* The padding character

#### Return:

* **String** The padding result

### _toSnakeCase(str)

Converts a string to snake case

#### Params:

* **String** *str*

#### Return:

* **String**

## Documentation generation
Documentation was partially generated with `markdox` with smaller tweaks over
the generated markdown file.

You can reproduce it running `npm run cc && markdox lib/index.js`, which should
generate a mostly correct documentation, depending on how lucky we are about
where the coffee-script compiler puts our comments.

## Code coverage generation
`npm run coverage` runs tests and generates an HTML code-coverage report.

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