1.1.1 • Published 2 years ago

duration-to-seconds v1.1.1

Weekly downloads
33
License
MIT
Repository
github
Last release
2 years ago

duration-to-seconds

build status npm version bundle size

Converts an ISO 8601 duration to seconds

Installing

npm install duration-to-seconds

API

durationToSeconds(duration)

Converts the given ISO 8601 duration to seconds. A year ("Y") is regarded as 365 days. A month ("M") is regarded as 30 days. The behaviour is undefined when not given an ISO 8601 compliant string.

import durationToSeconds from "duration-to-seconds";

durationToSeconds("PT0.001S"); // => 0.001
durationToSeconds("PT0.000001S"); // => 0.000001
durationToSeconds("PT1S"); // => 1
durationToSeconds("PT1M"); // => 60
durationToSeconds("PT1H"); // => 3600
durationToSeconds("P1D"); // => 86400
durationToSeconds("P1W"); // => 604800
durationToSeconds("P1M"); // => 2592000
durationToSeconds("P1Y"); // => 31536000
durationToSeconds("P1Y1M1DT1H1M1S"); // => 34218061
1.1.1

2 years ago

1.1.0

3 years ago

1.0.2

4 years ago

1.0.1

5 years ago

1.0.0

5 years ago

1.0.0-rc.2

5 years ago

1.0.0-rc.1

5 years ago

1.0.0-rc.0

6 years ago

1.0.0-beta.0

6 years ago