Socket
Book a DemoInstallSign in
Socket

duration-to-seconds

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

duration-to-seconds

Converts an ISO 8601 duration to seconds

2.0.0
latest
Source
npmnpm
Version published
Weekly downloads
80
-17.53%
Maintainers
1
Weekly downloads
 
Created
Source

duration-to-seconds

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

Keywords

convert

FAQs

Package last updated on 30 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.