iso8601-duration
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -24,2 +24,12 @@ 'use strict'; | ||
var defaultDuration = Object.freeze({ | ||
years: 0, | ||
months: 0, | ||
weeks: 0, | ||
days: 0, | ||
hours: 0, | ||
minutes: 0, | ||
seconds: 0 | ||
}); | ||
/** | ||
@@ -50,2 +60,4 @@ * The ISO8601 regex for matching / testing durations | ||
var end = exports.end = function end(duration, startDate) { | ||
duration = Object.assign({}, defaultDuration, duration); | ||
// Create two equal timestamps, add duration to 'then' and return time difference | ||
@@ -76,2 +88,4 @@ var timestamp = startDate ? startDate.getTime() : Date.now(); | ||
var toSeconds = exports.toSeconds = function toSeconds(duration, startDate) { | ||
duration = Object.assign({}, defaultDuration, duration); | ||
var timestamp = startDate ? startDate.getTime() : Date.now(); | ||
@@ -78,0 +92,0 @@ var now = new Date(timestamp); |
{ | ||
"name": "iso8601-duration", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Node/Js-module for parsing and making sense of ISO8601-durations", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -19,2 +19,12 @@ /** | ||
const defaultDuration = Object.freeze({ | ||
years: 0, | ||
months: 0, | ||
weeks: 0, | ||
days: 0, | ||
hours: 0, | ||
minutes: 0, | ||
seconds: 0 | ||
}) | ||
/** | ||
@@ -45,2 +55,4 @@ * The ISO8601 regex for matching / testing durations | ||
export const end = (duration, startDate) => { | ||
duration = Object.assign({}, defaultDuration, duration) | ||
// Create two equal timestamps, add duration to 'then' and return time difference | ||
@@ -71,2 +83,4 @@ const timestamp = (startDate ? startDate.getTime() : Date.now()) | ||
export const toSeconds = (duration, startDate) => { | ||
duration = Object.assign({}, defaultDuration, duration) | ||
const timestamp = (startDate ? startDate.getTime() : Date.now()) | ||
@@ -73,0 +87,0 @@ const now = new Date(timestamp) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10615
187