Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

iso8601-duration

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iso8601-duration

Node/Js-module for parsing and making sense of ISO8601-durations

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
324K
decreased by-19.43%
Maintainers
1
Weekly downloads
 
Created

What is iso8601-duration?

The iso8601-duration npm package is a utility for parsing, encoding, and manipulating ISO 8601 durations. It provides a simple interface to work with durations specified in the ISO 8601 format, which is commonly used in various applications and systems for representing time intervals.

What are iso8601-duration's main functionalities?

Parsing ISO 8601 Duration Strings

This feature allows you to parse an ISO 8601 duration string into a JavaScript object. The parsed object contains properties for years, months, days, hours, minutes, and seconds.

const iso8601Duration = require('iso8601-duration');
const duration = iso8601Duration.parse('P1Y2M10DT2H30M');
console.log(duration);

Encoding Durations to ISO 8601 Strings

This feature allows you to encode a JavaScript object representing a duration into an ISO 8601 duration string.

const iso8601Duration = require('iso8601-duration');
const duration = { years: 1, months: 2, days: 10, hours: 2, minutes: 30 };
const durationString = iso8601Duration.encode(duration);
console.log(durationString);

Adding Durations

This feature allows you to add two durations together, resulting in a new duration object.

const iso8601Duration = require('iso8601-duration');
const duration1 = iso8601Duration.parse('P1Y2M10DT2H30M');
const duration2 = iso8601Duration.parse('P0Y1M5DT1H15M');
const addedDuration = iso8601Duration.add(duration1, duration2);
console.log(addedDuration);

Subtracting Durations

This feature allows you to subtract one duration from another, resulting in a new duration object.

const iso8601Duration = require('iso8601-duration');
const duration1 = iso8601Duration.parse('P1Y2M10DT2H30M');
const duration2 = iso8601Duration.parse('P0Y1M5DT1H15M');
const subtractedDuration = iso8601Duration.subtract(duration1, duration2);
console.log(subtractedDuration);

Other packages similar to iso8601-duration

Keywords

FAQs

Package last updated on 18 Jan 2016

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