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

date-duration

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

date-duration

Manipulate Date objects with ISO 8601-formatted durations

  • 1.7.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
148
decreased by-29.19%
Maintainers
1
Weekly downloads
 
Created
Source

date-duration Build status

Manipulate Date objects with ISO 8601-formatted durations.

Installation

$ npm install date-duration

Usage

import Duration from 'date-duration';

let duration = Duration('PT1H');
// or
let duration = Duration({P: {T: {H: 1}}});

API

Duration(ISOString)

Pass a string in ISO 8601 duration format to create a duration.

duration.addTo(Date)

Add the duration to a Date object and returns the new date. Objects with a .toDate() (like Moment.js) method are converted to a regular Date object.

duration.subtractFrom(Date)

Subtract the duration from a Date object and returns the new date. Objects with a .toDate() method are converted to a regular Date object.

duration.add(Duration)

Add durations together returning a new duration which is the sum of both.

duration.multiply(number)

Multiply individual parts of duration returning a new duration as the result.

duration.toString()

Convert a duration back to a string in ISO 8601 format.

Keywords

FAQs

Package last updated on 20 Feb 2019

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