Comparing version 2.7.0 to 2.7.1
{ | ||
"name": "edtf", | ||
"version": "2.7.0", | ||
"version": "2.7.1", | ||
"description": "Extended Date Time Format (EDTF) / ISO 8601-2 Parser and Library", | ||
@@ -42,6 +42,6 @@ "main": "index.js", | ||
"chai": "^4.2.0", | ||
"eslint": "^6.3.0", | ||
"eslint": "^6.6.0", | ||
"istanbul": "^0.4.3", | ||
"mocha": "^6.2.0" | ||
"mocha": "^6.2.2" | ||
} | ||
} |
@@ -12,3 +12,3 @@ 'use strict' | ||
const { pow, max, min } = Math | ||
const { floor, pow, max, min } = Math | ||
@@ -129,3 +129,4 @@ | ||
max([year, month, day]) { // eslint-disable-line complexity | ||
// eslint-disable-next-line complexity | ||
max([year, month, day]) { | ||
if (!year) return [] | ||
@@ -186,2 +187,43 @@ | ||
// eslint-disable-next-line complexity | ||
min([year, month, day]) { | ||
if (!year) return [] | ||
year = Number( | ||
(this.test(Bitmask.YEAR)) ? this.masks([year], '0')[0] : year | ||
) | ||
if (!month) return [year] | ||
month = Number(month) - 1 | ||
switch (this.test(Bitmask.MONTH)) { | ||
case Bitmask.MONTH: | ||
case Bitmask.XM: | ||
month = 0 | ||
break | ||
case Bitmask.MX: | ||
month = (month < 9) ? 0 : 9 | ||
break | ||
} | ||
if (!day) return [year, month] | ||
day = Number(day) | ||
switch (this.test(Bitmask.DAY)) { | ||
case Bitmask.DAY: | ||
day = 1 | ||
break | ||
case Bitmask.DX: | ||
day = max(1, floor(day / 10) * 10) | ||
break | ||
case Bitmask.XD: | ||
day = max(1, day % 10) | ||
break | ||
} | ||
return [year, month, day] | ||
} | ||
marks(values, symbol = '?') { | ||
@@ -188,0 +230,0 @@ return values |
@@ -186,3 +186,9 @@ 'use strict' | ||
if (unspecified.value) { | ||
values = unspecified.max(values.map(Date.pad)) | ||
let bc = values[0] < 0 | ||
values = (k < 0) ^ bc ? | ||
unspecified.min(values.map(Date.pad)) : | ||
unspecified.max(values.map(Date.pad)) | ||
if (bc) values[0] = -values[0] | ||
} | ||
@@ -189,0 +195,0 @@ |
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
125777
2006