@briza/wegood
Advanced tools
Comparing version 1.0.5 to 1.0.6
# wegood changelog | ||
## 1.0.6 | ||
* Bug fix: re-instate timezone dependency, but local timezone offset instead. | ||
## 1.0.5 | ||
@@ -4,0 +8,0 @@ |
function _typeof(obj) { | ||
"@babel/helpers - typeof"; | ||
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { | ||
@@ -255,2 +257,21 @@ _typeof = function (obj) { | ||
/** | ||
* Get local timezone offset as ISO string | ||
* E.g. '-05:00' | ||
* @return {string} ISO timezone offset string | ||
*/ | ||
function getISOTimezoneOffset() { | ||
function pad(value) { | ||
return value < 10 ? '0' + value : value; | ||
} | ||
var date = new Date(); | ||
var sign = date.getTimezoneOffset() > 0 ? '-' : '+'; | ||
var offset = Math.abs(date.getTimezoneOffset()); | ||
var hours = pad(Math.floor(offset / 60)); | ||
var minutes = pad(offset % 60); | ||
return sign + hours + ':' + minutes; | ||
} | ||
/** | ||
* Date validation rule. | ||
@@ -297,3 +318,3 @@ * The value passed into the validation function must be a Date object | ||
} else if (value.match(/^\d{4}-[0,1]\d-[0-3]\d$/)) { | ||
value = new Date("".concat(value, "T00:00:00")); // Invalid | ||
value = new Date("".concat(value, "T00:00:00").concat(getISOTimezoneOffset())); // Invalid | ||
} else { | ||
@@ -300,0 +321,0 @@ console.warn("the date validation rule, invalid \"".concat(value, "\" date value")); |
@@ -6,2 +6,4 @@ 'use strict'; | ||
function _typeof(obj) { | ||
"@babel/helpers - typeof"; | ||
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { | ||
@@ -260,2 +262,21 @@ _typeof = function (obj) { | ||
/** | ||
* Get local timezone offset as ISO string | ||
* E.g. '-05:00' | ||
* @return {string} ISO timezone offset string | ||
*/ | ||
function getISOTimezoneOffset() { | ||
function pad(value) { | ||
return value < 10 ? '0' + value : value; | ||
} | ||
var date = new Date(); | ||
var sign = date.getTimezoneOffset() > 0 ? '-' : '+'; | ||
var offset = Math.abs(date.getTimezoneOffset()); | ||
var hours = pad(Math.floor(offset / 60)); | ||
var minutes = pad(offset % 60); | ||
return sign + hours + ':' + minutes; | ||
} | ||
/** | ||
* Date validation rule. | ||
@@ -302,3 +323,3 @@ * The value passed into the validation function must be a Date object | ||
} else if (value.match(/^\d{4}-[0,1]\d-[0-3]\d$/)) { | ||
value = new Date("".concat(value, "T00:00:00")); // Invalid | ||
value = new Date("".concat(value, "T00:00:00").concat(getISOTimezoneOffset())); // Invalid | ||
} else { | ||
@@ -305,0 +326,0 @@ console.warn("the date validation rule, invalid \"".concat(value, "\" date value")); |
{ | ||
"name": "@briza/wegood", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "Tiny validation library, so wegood with data.", | ||
@@ -5,0 +5,0 @@ "main": "lib/wegood.js", |
@@ -38,3 +38,3 @@ import { ValidationRule } from './rule'; | ||
*/ | ||
readonly rules: ValidationRule[]; | ||
get rules(): ValidationRule[]; | ||
/** | ||
@@ -41,0 +41,0 @@ * Validate against the value. |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
67952
1535
1