Comparing version 1.1.5 to 1.1.6
@@ -280,2 +280,17 @@ // == BDS2 LICENSE == | ||
/* | ||
* Is this a valid date that matches the given date mask | ||
* This is STRONGER validation than isValidDate and should be used | ||
* e.g., when validating dates entered in forms | ||
* | ||
* @param {String} timestamp | ||
* @param {String} mask [mask='MMMM D [at] h:mm a'] the date format mask to apply | ||
* | ||
* @return {Boolean} | ||
*/ | ||
isValidDateForMask: function(timestamp, mask) { | ||
var m = moment(timestamp, mask, true); | ||
// Be careful, if `value` is empty, `m` can be null | ||
return m && m.isValid(); | ||
}, | ||
/* | ||
* Parse a timestamp string using provided format and (optionally) timezone into a JavaScript Date | ||
@@ -316,2 +331,14 @@ * | ||
/* | ||
* Get the difference between two dates in the asked for units | ||
* | ||
* @param {String} timestampA | ||
* @param {String} timestampB | ||
* @param {String} units, a valid units identifier per moment e.g. days, hours, years ... | ||
* | ||
* @return {string} the difference between the two timestamps (which will be rounded down) | ||
*/ | ||
dateDifference: function(timestampA, timestampB, units) { | ||
return moment.utc(timestampA).diff(moment.utc(timestampB), units); | ||
}, | ||
/* | ||
*== CONSTANTS ==* | ||
@@ -318,0 +345,0 @@ */ |
{ | ||
"name": "sundial", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"description": "Tidepool's datetime wrapper", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
537
25273
6