New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
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
  • npm
  • Socket score

Version published
Maintainers
1
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

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc