# parse-iso-duration

> Parse an ISO 8601 duration to milliseconds

Latest version **1.1.0** (published 2019-08-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install parse-iso-duration
pnpm add parse-iso-duration
yarn add parse-iso-duration
bun add parse-iso-duration
```

## 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.1.0 |
| Published | 2019-08-04 |
| First published | 2015-01-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Linus Unnebäck |
| Maintainers | linusu |

## Links

- npm: https://www.npmjs.com/package/parse-iso-duration
- Repository: https://github.com/LinusU/node-parse-iso-duration
- Homepage: https://github.com/LinusU/node-parse-iso-duration#readme
- Issues: https://github.com/LinusU/node-parse-iso-duration/issues
- npm.io page: https://npm.io/package/parse-iso-duration

## Recent versions

- 1.1.0 (latest) — 2019-08-04
- 1.0.0 — 2015-08-16
- 0.1.2 — 2015-08-16
- 0.1.1 — 2015-08-02
- 0.1.0 — 2015-01-25

## README

# node-parse-iso-duration

Parse an ISO 8601 duration to milliseconds

## Instalation

```sh
npm install --save parse-iso-duration
```

## Usage

```javascript
var parseIsoDuration = require('parse-iso-duration');

parseIsoDuration('PT8S');   // 8 * 1000
parseIsoDuration('PT10M');  // 10 * 60 * 1000
parseIsoDuration('PT20H');  // 20 * 60 * 60 * 1000
parseIsoDuration('PT6M4S'); // 6 * 60 * 1000 + 4 * 1000

parseIsoDuration('Hello world'); // Throws "Invalid duration"
parseIsoDuration('P10Y10M10D');  // Throws "Ambiguous duration"
```

## Year and month

If years or months is specified and more than 0 the library will throw `"Ambiguous duration"` since it's meaning can't be converted to milliseconds.

## License

MIT

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