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 - npm Package Compare versions

Comparing version 1.6.0 to 1.7.0

47

dist/duration.js

@@ -99,2 +99,14 @@ "use strict";

};
var updateParts = function updateParts(parts, operator) {
return Object.keys(parts).reduce(function (result, key) {
if (key === 'T') {
result[key] = updateParts(parts[key], operator);
} else {
result[key] = operator(parts[key]);
}
return result;
}, {});
};
/**

@@ -136,5 +148,15 @@ * @constructor

}, {
/**
* Convert to a string in ISO 8601 notation
* @return {string}
*/
toString: function toString() {
return "P".concat(joinParts(parts, ['Y', 'M', 'W', 'D'])).concat(parts.T ? "T".concat(joinParts(parts.T, ['H', 'M', 'S'])) : '');
},
/**
* Add duration to a date
* @param {Date} date
* @return {Date}
*/
addTo: function addTo(date) {

@@ -145,2 +167,8 @@ return applyParts(clone(date), parts, methods, function (left, right) {

},
/**
* Subtract duration from a date
* @param {Date} date
* @return {Date}
*/
subtractFrom: function subtractFrom(date) {

@@ -151,2 +179,8 @@ return applyParts(clone(date), parts, methods, function (left, right) {

},
/**
* Add (merge) two durations
* @param {Duration} duration
* @return {Duration}
*/
add: function add(duration) {

@@ -158,2 +192,15 @@ return createDuration({

});
},
/**
* Multiply parts of the duration by a number
* @param {number} multiplier
* @return {Duration}
*/
multiply: function multiply(multiplier) {
return createDuration({
P: updateParts(parts, function (value) {
return value * multiplier;
})
});
}

@@ -160,0 +207,0 @@ }));

2

package.json
{
"name": "date-duration",
"version": "1.6.0",
"version": "1.7.0",
"description": "Manipulate Date objects with ISO 8601-formatted durations",

@@ -5,0 +5,0 @@ "main": "dist/duration.js",

@@ -32,3 +32,6 @@ date-duration [![Build status](https://api.travis-ci.org/smhg/date-duration.png)](https://travis-ci.org/smhg/date-duration)

### 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.

Sorry, the diff of this file is not supported yet

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