New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@flourish/interpreter

Package Overview
Dependencies
Maintainers
0
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@flourish/interpreter - npm Package Compare versions

Comparing version 9.0.0 to 9.1.0

544

interpreter.js

@@ -91,4 +91,2 @@ (function (global, factory) {

});
var timeDay = day;
day.range;

@@ -144,4 +142,2 @@

};
var timeYear = year;
year.range;

@@ -158,4 +154,2 @@

});
var utcDay$1 = utcDay;
utcDay.range;

@@ -211,4 +205,2 @@

};
var utcYear$1 = utcYear;
utcYear.range;

@@ -404,3 +396,3 @@

i = parseSpecifier(d, specifier, string += "", 0),
week, day;
week, day$1;
if (i != string.length) return null;

@@ -426,5 +418,5 @@

if ("Z" in d) {
week = utcDate(newDate(d.y, 0, 1)), day = week.getUTCDay();
week = day > 4 || day === 0 ? utcMonday.ceil(week) : utcMonday(week);
week = utcDay$1.offset(week, (d.V - 1) * 7);
week = utcDate(newDate(d.y, 0, 1)), day$1 = week.getUTCDay();
week = day$1 > 4 || day$1 === 0 ? utcMonday.ceil(week) : utcMonday(week);
week = utcDay.offset(week, (d.V - 1) * 7);
d.y = week.getUTCFullYear();

@@ -434,5 +426,5 @@ d.m = week.getUTCMonth();

} else {
week = localDate(newDate(d.y, 0, 1)), day = week.getDay();
week = day > 4 || day === 0 ? monday.ceil(week) : monday(week);
week = timeDay.offset(week, (d.V - 1) * 7);
week = localDate(newDate(d.y, 0, 1)), day$1 = week.getDay();
week = day$1 > 4 || day$1 === 0 ? monday.ceil(week) : monday(week);
week = day.offset(week, (d.V - 1) * 7);
d.y = week.getFullYear();

@@ -444,5 +436,5 @@ d.m = week.getMonth();

if (!("w" in d)) d.w = "u" in d ? d.u % 7 : "W" in d ? 1 : 0;
day = "Z" in d ? utcDate(newDate(d.y, 0, 1)).getUTCDay() : localDate(newDate(d.y, 0, 1)).getDay();
day$1 = "Z" in d ? utcDate(newDate(d.y, 0, 1)).getUTCDay() : localDate(newDate(d.y, 0, 1)).getDay();
d.m = 0;
d.d = "W" in d ? (d.w + 6) % 7 + d.W * 7 - (day + 5) % 7 : d.w + d.U * 7 - (day + 6) % 7;
d.d = "W" in d ? (d.w + 6) % 7 + d.W * 7 - (day$1 + 5) % 7 : d.w + d.U * 7 - (day$1 + 6) % 7;
}

@@ -733,3 +725,3 @@

function formatDayOfYear(d, p) {
return pad(1 + timeDay.count(timeYear(d), d), p, 3);
return pad(1 + day.count(year(d), d), p, 3);
}

@@ -763,3 +755,3 @@

function formatWeekNumberSunday(d, p) {
return pad(sunday.count(timeYear(d) - 1, d), p, 2);
return pad(sunday.count(year(d) - 1, d), p, 2);
}

@@ -774,3 +766,3 @@

d = dISO(d);
return pad(thursday.count(timeYear(d), d) + (timeYear(d).getDay() === 4), p, 2);
return pad(thursday.count(year(d), d) + (year(d).getDay() === 4), p, 2);
}

@@ -783,3 +775,3 @@

function formatWeekNumberMonday(d, p) {
return pad(monday.count(timeYear(d) - 1, d), p, 2);
return pad(monday.count(year(d) - 1, d), p, 2);
}

@@ -826,3 +818,3 @@

function formatUTCDayOfYear(d, p) {
return pad(1 + utcDay$1.count(utcYear$1(d), d), p, 3);
return pad(1 + utcDay.count(utcYear(d), d), p, 3);
}

@@ -856,3 +848,3 @@

function formatUTCWeekNumberSunday(d, p) {
return pad(utcSunday.count(utcYear$1(d) - 1, d), p, 2);
return pad(utcSunday.count(utcYear(d) - 1, d), p, 2);
}

@@ -867,3 +859,3 @@

d = UTCdISO(d);
return pad(utcThursday.count(utcYear$1(d), d) + (utcYear$1(d).getUTCDay() === 4), p, 2);
return pad(utcThursday.count(utcYear(d), d) + (utcYear(d).getUTCDay() === 4), p, 2);
}

@@ -876,3 +868,3 @@

function formatUTCWeekNumberMonday(d, p) {
return pad(utcMonday.count(utcYear$1(d) - 1, d), p, 2);
return pad(utcMonday.count(utcYear(d) - 1, d), p, 2);
}

@@ -940,7 +932,10 @@

function notAStringError(not_a_str) {
throw new TypeError("Expected a value of type string but got a value of type " + (typeof not_a_str));
throw new TypeError(
"Expected a value of type string but got a value of type " +
typeof not_a_str,
);
}
function shield(func) {
return function(str) {
return function (str) {
if (typeof str !== "string") notAStringError(str);

@@ -960,11 +955,17 @@ str = str.trim();

regex: /^june\s(30|[12][0-9]|0?[1-9])$/i, // matches dates from June 0-30
toDate: function(str) { return new Date(null, 5, str.split(/\s/)[1]); },
toDate: function (str) {
return new Date(null, 5, str.split(/\s/)[1]);
},
},
{
regex: /^july\s(3[01]|[12][0-9]|0?[1-9])$/i, // matches dates from July 0-31
toDate: function(str) { return new Date(null, 6, str.split(/\s/)[1]); },
toDate: function (str) {
return new Date(null, 6, str.split(/\s/)[1]);
},
},
{
regex: /^sept\s(30|[12][0-9]|0?[1-9])$/i, // matches dates from September 0-30 using the 4-letter 'Sept' abbreviation
toDate: function(str) { return new Date(null, 8, str.split(/\s/)[1]); },
toDate: function (str) {
return new Date(null, 8, str.split(/\s/)[1]);
},
},

@@ -977,11 +978,17 @@ ],

regex: /^(0?[1-9]|[1-9][0-9])\sjune$/i, // matches dates from 0-99 June
toDate: function(str) { return new Date(null, 5, str.split(/\s/)[0]); },
toDate: function (str) {
return new Date(null, 5, str.split(/\s/)[0]);
},
},
{
regex: /^(0?[1-9]|[1-9][0-9])\sjuly$/i, // matches dates from 0-99 July
toDate: function(str) { return new Date(null, 6, str.split(/\s/)[0]); },
toDate: function (str) {
return new Date(null, 6, str.split(/\s/)[0]);
},
},
{
regex: /^(0?[1-9]|[1-9][0-9])\ssept$/i, // matches dates from 0-99 September using the 4-letter 'Sept' abbreviation
toDate: function(str) { return new Date(null, 8, str.split(/\s/)[0]); },
toDate: function (str) {
return new Date(null, 8, str.split(/\s/)[0]);
},
},

@@ -994,5 +1001,5 @@ ],

function customDatetimeParser(strftime_formats) {
return function(str) {
return function (str) {
var parsed_datetime = null;
strftime_formats.forEach(function(strftime_format) {
strftime_formats.forEach(function (strftime_format) {
var valid_datetime = str.match(strftime_format.regex);

@@ -1010,20 +1017,28 @@ if (valid_datetime) parsed_datetime = strftime_format.toDate(str);

if (typeof secondaryTest === "function") {
test = shield(function(str) {
return (secondaryTest(str, parser(str) !== null));
test = shield(function (str) {
return secondaryTest(str, parser(str) !== null);
});
} else {
test = shield(function (str) {
return parser(str) !== null;
});
}
else {
test = shield(function(str) { return parser(str) !== null; });
}
return Object.freeze({
test: test,
parse: shield(function(str) {
return parser(str) || (CUSTOM_FORMAT_REGEXES[format_string] ? customDatetimeParser(CUSTOM_FORMAT_REGEXES[format_string])(str) : null);
parse: shield(function (str) {
return (
parser(str) ||
(CUSTOM_FORMAT_REGEXES[format_string]
? customDatetimeParser(CUSTOM_FORMAT_REGEXES[format_string])(str)
: null)
);
}),
format: function(dt) { return formatter(dt); },
format: function (dt) {
return formatter(dt);
},
type: "datetime",
description: format_string,
id: "datetime$" + format_string,
example: formatter(EXAMPLE_DATETIME)
example: formatter(EXAMPLE_DATETIME),
});

@@ -1038,86 +1053,150 @@ }

createDatetimeInterpretation("%d/%m/%Y", function(str, passed_primary_test) { // 27/04/1972
createDatetimeInterpretation("%d/%m/%Y", function (str, passed_primary_test) {
// 27/04/1972
if (!passed_primary_test) return false;
var arr = str.split("/").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 31) && (arr[1] > 0 && arr[1] <= 12) && (arr[2] >= 1000);
return (
arr[0] > 0 && arr[0] <= 31 && arr[1] > 0 && arr[1] <= 12 && arr[2] >= 1000
);
}),
createDatetimeInterpretation("%d/%m/%Y %H:%M", function(str, passed_primary_test) { // 27/04/1972 19:45
createDatetimeInterpretation(
"%d/%m/%Y %H:%M",
function (str, passed_primary_test) {
// 27/04/1972 19:45
if (!passed_primary_test) return false;
var arr = str.split(/[/ :]/).map(parseFloat);
return (
arr[0] > 0 &&
arr[0] <= 31 &&
arr[1] > 0 &&
arr[1] <= 12 &&
arr[2] >= 1000 &&
arr[3] >= 0 &&
arr[3] < 24 &&
arr[4] >= 0 &&
arr[4] < 60
);
},
),
createDatetimeInterpretation("%d/%m/%y", function (str, passed_primary_test) {
// 27/04/72
if (!passed_primary_test) return false;
var arr = str.split(/[/ :]/).map(parseFloat);
return (arr[0] > 0 && arr[0] <= 31) && (arr[1] > 0 && arr[1] <= 12) && (arr[2] >= 1000) &&
(arr[3] >= 0 && arr[3] < 24) && (arr[4] >= 0 && arr[4] < 60);
}),
createDatetimeInterpretation("%d/%m/%y", function(str, passed_primary_test) { // 27/04/72
if (!passed_primary_test) return false;
var arr = str.split("/").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 31) && (arr[1] > 0 && arr[1] <= 12) && (!isNaN(arr[2]));
return (
arr[0] > 0 && arr[0] <= 31 && arr[1] > 0 && arr[1] <= 12 && !isNaN(arr[2])
);
}),
createDatetimeInterpretation("%m/%d/%Y", function(str, passed_primary_test) { // 04/27/1972
createDatetimeInterpretation("%m/%d/%Y", function (str, passed_primary_test) {
// 04/27/1972
if (!passed_primary_test) return false;
var arr = str.split("/").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 12) && (arr[1] > 0 && arr[1] <= 31) && (arr[2] >= 1000);
return (
arr[0] > 0 && arr[0] <= 12 && arr[1] > 0 && arr[1] <= 31 && arr[2] >= 1000
);
}),
createDatetimeInterpretation("%m/%d/%Y %H:%M", function(str, passed_primary_test) { // 04/27/1972 19:45
createDatetimeInterpretation(
"%m/%d/%Y %H:%M",
function (str, passed_primary_test) {
// 04/27/1972 19:45
if (!passed_primary_test) return false;
var arr = str.split(/[/ :]/).map(parseFloat);
return (
arr[0] > 0 &&
arr[0] <= 12 &&
arr[1] > 0 &&
arr[1] <= 31 &&
arr[2] >= 1000 &&
arr[3] >= 0 &&
arr[3] < 24 &&
arr[4] >= 0 &&
arr[4] < 60
);
},
),
createDatetimeInterpretation("%m/%d/%y", function (str, passed_primary_test) {
// 04/27/72
if (!passed_primary_test) return false;
var arr = str.split(/[/ :]/).map(parseFloat);
return (arr[0] > 0 && arr[0] <= 12) && (arr[1] > 0 && arr[1] <= 31) && (arr[2] >= 1000) &&
(arr[3] >= 0 && arr[3] < 24) && (arr[4] >= 0 && arr[4] < 60);
}),
createDatetimeInterpretation("%m/%d/%y", function(str, passed_primary_test) { // 04/27/72
if (!passed_primary_test) return false;
var arr = str.split("/").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 12) && (arr[1] > 0 && arr[1] <= 31) && (!isNaN(arr[2]));
return (
arr[0] > 0 && arr[0] <= 12 && arr[1] > 0 && arr[1] <= 31 && !isNaN(arr[2])
);
}),
createDatetimeInterpretation("%Y/%m/%d", function(str, passed_primary_test) { // 1972/04/27
createDatetimeInterpretation("%Y/%m/%d", function (str, passed_primary_test) {
// 1972/04/27
if (!passed_primary_test) return false;
var arr = str.split("/").map(parseFloat);
return (arr[0] >= 1000) && (arr[1] > 0 && arr[1] <= 12) && (arr[2] > 0 && arr[2] <= 31);
return (
arr[0] >= 1000 && arr[1] > 0 && arr[1] <= 12 && arr[2] > 0 && arr[2] <= 31
);
}),
createDatetimeInterpretation("%d-%m-%Y", function(str, passed_primary_test) { // 27-04-1972
createDatetimeInterpretation("%d-%m-%Y", function (str, passed_primary_test) {
// 27-04-1972
if (!passed_primary_test) return false;
var arr = str.split("-").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 31) && (arr[1] > 0 && arr[1] <= 12) && (arr[2] >= 1000);
return (
arr[0] > 0 && arr[0] <= 31 && arr[1] > 0 && arr[1] <= 12 && arr[2] >= 1000
);
}),
createDatetimeInterpretation("%d-%m-%y", function(str, passed_primary_test) { // 27-04-72
createDatetimeInterpretation("%d-%m-%y", function (str, passed_primary_test) {
// 27-04-72
if (!passed_primary_test) return false;
var arr = str.split("-").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 31) && (arr[1] > 0 && arr[1] <= 12) && (!isNaN(arr[2]));
return (
arr[0] > 0 && arr[0] <= 31 && arr[1] > 0 && arr[1] <= 12 && !isNaN(arr[2])
);
}),
createDatetimeInterpretation("%d.%m.%Y", function(str, passed_primary_test) { // 27.04.1972
createDatetimeInterpretation("%d.%m.%Y", function (str, passed_primary_test) {
// 27.04.1972
if (!passed_primary_test) return false;
var arr = str.split(".").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 31) && (arr[1] > 0 && arr[1] <= 12) && (arr[2] >= 1000);
return (
arr[0] > 0 && arr[0] <= 31 && arr[1] > 0 && arr[1] <= 12 && arr[2] >= 1000
);
}),
createDatetimeInterpretation("%m.%d.%y", function(str, passed_primary_test) { // 04.27.72
createDatetimeInterpretation("%m.%d.%y", function (str, passed_primary_test) {
// 04.27.72
if (!passed_primary_test) return false;
var arr = str.split(".").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 12) && (arr[1] > 0 && arr[1] <= 31) && (!isNaN(arr[2]));
return (
arr[0] > 0 && arr[0] <= 12 && arr[1] > 0 && arr[1] <= 31 && !isNaN(arr[2])
);
}),
createDatetimeInterpretation("%m-%d-%Y", function(str, passed_primary_test) { // 04-27-1972
createDatetimeInterpretation("%m-%d-%Y", function (str, passed_primary_test) {
// 04-27-1972
if (!passed_primary_test) return false;
var arr = str.split("-").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 12) && (arr[1] > 0 && arr[1] <= 31) && (arr[2] >= 1000);
return (
arr[0] > 0 && arr[0] <= 12 && arr[1] > 0 && arr[1] <= 31 && arr[2] >= 1000
);
}),
createDatetimeInterpretation("%m-%d-%y", function(str, passed_primary_test) { // 04-27-72
createDatetimeInterpretation("%m-%d-%y", function (str, passed_primary_test) {
// 04-27-72
if (!passed_primary_test) return false;
var arr = str.split("-").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 12) && (arr[1] > 0 && arr[1] <= 31) && (!isNaN(arr[2]));
return (
arr[0] > 0 && arr[0] <= 12 && arr[1] > 0 && arr[1] <= 31 && !isNaN(arr[2])
);
}),
createDatetimeInterpretation("%Y-%m-%d", function(str, passed_primary_test) { // 1972-04-27
createDatetimeInterpretation("%Y-%m-%d", function (str, passed_primary_test) {
// 1972-04-27
if (!passed_primary_test) return false;
var arr = str.split("-").map(parseFloat);
return (arr[0] >= 1000) && (arr[1] > 0 && arr[1] <= 12) && (arr[2] > 0 && arr[2] <= 31);
return (
arr[0] >= 1000 && arr[1] > 0 && arr[1] <= 12 && arr[2] > 0 && arr[2] <= 31
);
}),
createDatetimeInterpretation("%Y-%m", function(str, passed_primary_test) { // 1972-04
createDatetimeInterpretation("%Y-%m", function (str, passed_primary_test) {
// 1972-04
if (!passed_primary_test) return false;
var arr = str.split("-").map(parseFloat);
return (arr[0] >= 1000) && (arr[1] > 0 && arr[1] <= 12);
return arr[0] >= 1000 && arr[1] > 0 && arr[1] <= 12;
}),
createDatetimeInterpretation("%Y%m", function(str, passed_primary_test) { // 197204
createDatetimeInterpretation("%Y%m", function (str, passed_primary_test) {
// 197204
if (!passed_primary_test) return false;

@@ -1129,11 +1208,13 @@ var year = parseFloat(str.slice(0, 4));

createDatetimeInterpretation("%d %b %Y", function(str, passed_primary_test) { // 27 Apr 1972
createDatetimeInterpretation("%d %b %Y", function (str, passed_primary_test) {
// 27 Apr 1972
if (!passed_primary_test) return false;
var arr = str.split(" ").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 31) && (arr[2] >= 1000);
return arr[0] > 0 && arr[0] <= 31 && arr[2] >= 1000;
}),
createDatetimeInterpretation("%d %B %Y", function(str, passed_primary_test) { // 27 April 1972
createDatetimeInterpretation("%d %B %Y", function (str, passed_primary_test) {
// 27 April 1972
if (!passed_primary_test) return false;
var arr = str.split(" ").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 31) && (arr[2] >= 1000);
return arr[0] > 0 && arr[0] <= 31 && arr[2] >= 1000;
}),

@@ -1143,11 +1224,13 @@ createDatetimeInterpretation("%d %b %y"), // 27 Apr 72

createDatetimeInterpretation("%d %B %y"), // 27 April 72
createDatetimeInterpretation("%d-%b-%Y", function(str, passed_primary_test) { // 27-Apr-1972
createDatetimeInterpretation("%d-%b-%Y", function (str, passed_primary_test) {
// 27-Apr-1972
if (!passed_primary_test) return false;
var arr = str.split("-").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 31) && (arr[2] >= 1000);
return arr[0] > 0 && arr[0] <= 31 && arr[2] >= 1000;
}),
createDatetimeInterpretation("%d-%B-%Y", function(str, passed_primary_test) { // 27-April-1972
createDatetimeInterpretation("%d-%B-%Y", function (str, passed_primary_test) {
// 27-April-1972
if (!passed_primary_test) return false;
var arr = str.split("-").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 31) && (arr[2] >= 1000);
return arr[0] > 0 && arr[0] <= 31 && arr[2] >= 1000;
}),

@@ -1157,17 +1240,20 @@ createDatetimeInterpretation("%d-%b-%y"), // 27-Apr-72

createDatetimeInterpretation("%m/%Y", function(str, passed_primary_test) { // 04/1972
createDatetimeInterpretation("%m/%Y", function (str, passed_primary_test) {
// 04/1972
if (!passed_primary_test) return false;
var arr = str.split("/").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 12) && (arr[1] >= 1000);
return arr[0] > 0 && arr[0] <= 12 && arr[1] >= 1000;
}),
createDatetimeInterpretation("%m/%y"), // 04/72
createDatetimeInterpretation("%b %Y", function(str, passed_primary_test) { // Apr 1972
createDatetimeInterpretation("%b %Y", function (str, passed_primary_test) {
// Apr 1972
if (!passed_primary_test) return false;
var arr = str.split(" ").map(parseFloat);
return (arr[1] >= 1000);
return arr[1] >= 1000;
}),
createDatetimeInterpretation("%B %Y", function(str, passed_primary_test) { // April 1972
createDatetimeInterpretation("%B %Y", function (str, passed_primary_test) {
// April 1972
if (!passed_primary_test) return false;
var arr = str.split(" ").map(parseFloat);
return (arr[1] >= 1000);
return arr[1] >= 1000;
}),

@@ -1181,3 +1267,3 @@ createDatetimeInterpretation("%b-%y"), // Apr-72

createDatetimeInterpretation("%d %b", function(str, passed_primary_test) {
createDatetimeInterpretation("%d %b", function (str, passed_primary_test) {
if (passed_primary_test) return true;

@@ -1187,3 +1273,3 @@ return !!customDatetimeParser(CUSTOM_FORMAT_REGEXES["%d %b"])(str);

createDatetimeInterpretation("%d %B"), // 27 April
createDatetimeInterpretation("%b %d", function(str, passed_primary_test) {
createDatetimeInterpretation("%b %d", function (str, passed_primary_test) {
if (passed_primary_test) return true;

@@ -1193,6 +1279,7 @@ return !!customDatetimeParser(CUSTOM_FORMAT_REGEXES["%b %d"])(str);

createDatetimeInterpretation("%B %d"), // April 27
createDatetimeInterpretation("%d-%m", function(str, passed_primary_test) { // 27-04
createDatetimeInterpretation("%d-%m", function (str, passed_primary_test) {
// 27-04
if (!passed_primary_test) return false;
var arr = str.split("-").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 31) && (arr[1] > 0 && arr[1] <= 12);
return arr[0] > 0 && arr[0] <= 31 && arr[1] > 0 && arr[1] <= 12;
}),

@@ -1205,3 +1292,4 @@ createDatetimeInterpretation("%m-%d"), // 04-27

createDatetimeInterpretation("%Y", function(str, passed_primary_test) { // 1972
createDatetimeInterpretation("%Y", function (str, passed_primary_test) {
// 1972
if (!passed_primary_test) return false;

@@ -1217,3 +1305,4 @@ var val = parseFloat(str);

createDatetimeInterpretation("%-I.%M%p"), // 7.45PM
createDatetimeInterpretation("%H:%M", function(str, passed_primary_test) { // 19:45
createDatetimeInterpretation("%H:%M", function (str, passed_primary_test) {
// 19:45
if (!passed_primary_test) return false;

@@ -1227,10 +1316,30 @@ var arr = str.split(":").map(parseFloat);

createDatetimeInterpretation("Q%q %Y", function(str, passed_primary_test) { // Q2 1972
createDatetimeInterpretation("Q%q %Y", function (str, passed_primary_test) {
// Q2 1972
if (!passed_primary_test) return false;
return str.replace(/\s/g, "").length === 6;
}),
createDatetimeInterpretation("%Y Q%q", function(str, passed_primary_test) { // 1972 Q2
createDatetimeInterpretation("%Y Q%q", function (str, passed_primary_test) {
// 1972 Q2
if (!passed_primary_test) return false;
return str.replace(/\s/g, "").length === 6;
})
}),
createDatetimeInterpretation("%YM%m", function (str, passed_primary_test) {
// 1972M04
if (!passed_primary_test) return false;
var arr = str.split("M").map(parseFloat);
return arr[0] >= 1000 && arr[1] > 0 && arr[1] <= 12;
}),
createDatetimeInterpretation("%YQ%q", function (str, passed_primary_test) {
// 1972Q2
if (!passed_primary_test) return false;
var arr = str.split("Q").map(parseFloat);
return arr[0] >= 1000 && arr[1] > 0 && arr[1] <= 4;
}),
createDatetimeInterpretation("%YÁ%q", function (str, passed_primary_test) {
// 1972Á2
if (!passed_primary_test) return false;
var arr = str.split("Á").map(parseFloat);
return arr[0] >= 1000 && arr[1] > 0 && arr[1] <= 4;
}),
]);

@@ -1538,6 +1647,11 @@

var thousands = interp.thousand_separator;
var locale = formatLocale({decimal: decimal, thousands: thousands, grouping: [3], currency: ["", ""]});
var locale = formatLocale({
decimal: decimal,
thousands: thousands,
grouping: [3],
currency: ["", ""],
});
var format, specifier;
return function(value, spec) {
return function (value, spec) {
if (value === null) return "";

@@ -1555,4 +1669,10 @@ if (!spec) spec = ",.2f";

var comma_point = {
test: shield(function(str) { return /^(\+|-)?\d{1,3}(,\d{3})*(\.\d+)?((e|E)(\+|-)?\d+)?$/.test(str.trim()); }),
parse: shield(function(str) { return parseFloat(str.replace(/,/g, "")); }),
test: shield(function (str) {
return /^(\+|-)?\d{1,3}(,\d{3})*(\.\d+)?((e|E)(\+|-)?\d+)?$/.test(
str.trim(),
);
}),
parse: shield(function (str) {
return parseFloat(str.replace(/,/g, ""));
}),
description: "Comma thousand separator, point decimal mark",

@@ -1562,8 +1682,14 @@ thousand_separator: ",",

id: "number$comma_point",
example: "12,235.56"
example: "12,235.56",
};
var space_point = {
test: shield(function(str) { return /^(\+|-)?\d{1,3}(\s\d{3})*(\.\d+)?((e|E)(\+|-)?\d+)?$/.test(str.trim()); }),
parse: shield(function(str) { return parseFloat(str.replace(/\s/g, "")); }),
test: shield(function (str) {
return /^(\+|-)?\d{1,3}(\s\d{3})*(\.\d+)?((e|E)(\+|-)?\d+)?$/.test(
str.trim(),
);
}),
parse: shield(function (str) {
return parseFloat(str.replace(/\s/g, ""));
}),
description: "Space thousand separator, point decimal mark",

@@ -1573,8 +1699,12 @@ thousand_separator: " ",

id: "number$space_point",
example: "12 235.56"
example: "12 235.56",
};
var none_point = {
test: shield(function(str) { return /^(\+|-)?\d+(\.\d+)?((e|E)(\+|-)?\d+)?$/.test(str.trim()); }),
parse: shield(function(str) { return parseFloat(str); }),
test: shield(function (str) {
return /^(\+|-)?\d+(\.\d+)?((e|E)(\+|-)?\d+)?$/.test(str.trim());
}),
parse: shield(function (str) {
return parseFloat(str);
}),
description: "No thousand separator, point decimal mark",

@@ -1584,8 +1714,14 @@ thousand_separator: "",

id: "number$none_point",
example: "12235.56"
example: "12235.56",
};
var point_comma = {
test: shield(function(str) { return /^(\+|-)?\d{1,3}(\.\d{3})*(,\d+)?((e|E)(\+|-)?\d+)?$/.test(str.trim()); }),
parse: shield(function(str) { return parseFloat(str.replace(/\./g, "").replace(/,/, ".")); }),
test: shield(function (str) {
return /^(\+|-)?\d{1,3}(\.\d{3})*(,\d+)?((e|E)(\+|-)?\d+)?$/.test(
str.trim(),
);
}),
parse: shield(function (str) {
return parseFloat(str.replace(/\./g, "").replace(/,/, "."));
}),
description: "Point thousand separator, comma decimal mark",

@@ -1595,8 +1731,14 @@ thousand_separator: ".",

id: "number$point_comma",
example: "12.235,56"
example: "12.235,56",
};
var space_comma = {
test: shield(function(str) { return /^(\+|-)?\d{1,3}(\s\d{3})*(,\d+)?((e|E)(\+|-)?\d+)?$/.test(str.trim()); }),
parse: shield(function(str) { return parseFloat(str.replace(/\s/g, "").replace(/,/, ".")); }),
test: shield(function (str) {
return /^(\+|-)?\d{1,3}(\s\d{3})*(,\d+)?((e|E)(\+|-)?\d+)?$/.test(
str.trim(),
);
}),
parse: shield(function (str) {
return parseFloat(str.replace(/\s/g, "").replace(/,/, "."));
}),
description: "Space thousand separator, comma decimal mark",

@@ -1606,8 +1748,12 @@ thousand_separator: " ",

id: "number$space_comma",
example: "12 235,56"
example: "12 235,56",
};
var none_comma = {
test: shield(function(str) { return /^(\+|-)?\d+(,\d+)?((e|E)(\+|-)?\d+)?$/.test(str.trim()); }),
parse: shield(function(str) { return parseFloat(str.replace(/,/, ".")); }),
test: shield(function (str) {
return /^(\+|-)?\d+(,\d+)?((e|E)(\+|-)?\d+)?$/.test(str.trim());
}),
parse: shield(function (str) {
return parseFloat(str.replace(/,/, "."));
}),
description: "No thousand separator, comma decimal mark",

@@ -1617,3 +1763,3 @@ thousand_separator: "",

id: "number$none_comma",
example: "12235,56"
example: "12235,56",
};

@@ -1627,6 +1773,6 @@

none_point,
none_comma
none_comma,
]);
number_interpretations.forEach(function(interp) {
number_interpretations.forEach(function (interp) {
interp.type = "number";

@@ -1638,8 +1784,14 @@ interp.format = getFormatFunction(interp);

var string_interpretation = Object.freeze({
test: function(str) { return typeof str === "string" ? true : notAStringError(str); },
parse: function(str) { return typeof str === "string" ? str : notAStringError(str); },
format: function(str) { if (typeof str === "string") return str; },
test: function (str) {
return typeof str === "string" ? true : notAStringError(str);
},
parse: function (str) {
return typeof str === "string" ? str : notAStringError(str);
},
format: function (str) {
if (typeof str === "string") return str;
},
type: "string",
description: "Arbitrary string",
id: "string$arbitrary_string"
id: "string$arbitrary_string",
});

@@ -1652,3 +1804,7 @@

var DEFAULT_INTERPRETATIONS_ARRAY = Object.freeze([ "datetime", "number", "string" ]);
var DEFAULT_INTERPRETATIONS_ARRAY = Object.freeze([
"datetime",
"number",
"string",
]);

@@ -1659,3 +1815,3 @@ var DEFAULT_OPTIONS = Object.freeze({

failure_fraction: 5 / 100,
sort: true
sort: true,
});

@@ -1666,3 +1822,3 @@

function snakeToCamel(snake_string) {
return snake_string.replace(/_(\w)/g, function(match, capture) {
return snake_string.replace(/_(\w)/g, function (match, capture) {
return capture.toUpperCase();

@@ -1672,4 +1828,8 @@ });

function noSort(a, b) { return a.index - b.index; }
function sortBySuccess(a, b) { return b.n_success - a.n_success || noSort(a, b); }
function noSort(a, b) {
return a.index - b.index;
}
function sortBySuccess(a, b) {
return b.n_success - a.n_success || noSort(a, b);
}

@@ -1681,12 +1841,25 @@ function trim(value) {

function createAccessorFunction(accessor) {
if (accessor === undefined) return function(value) { return trim(value); };
if (typeof accessor === "function") return function(value, index) { return trim(accessor(value, index)); };
return function(value) { return trim(value["" + accessor]); };
if (accessor === undefined)
return function (value) {
return trim(value);
};
if (typeof accessor === "function")
return function (value, index) {
return trim(accessor(value, index));
};
return function (value) {
return trim(value["" + accessor]);
};
}
function createInterpreter(interpretations_array) {
if (!interpretations_array) interpretations_array = DEFAULT_INTERPRETATIONS_ARRAY;
else if (!Array.isArray(interpretations_array)) interpretations_array = [interpretations_array];
if (!interpretations_array)
interpretations_array = DEFAULT_INTERPRETATIONS_ARRAY;
else if (!Array.isArray(interpretations_array))
interpretations_array = [interpretations_array];
var interpretations = interpretations_array.reduce(function(arr, interp_string) {
var interpretations = interpretations_array.reduce(function (
arr,
interp_string,
) {
var interps = INTERPRETATION_OPTIONS[interp_string];

@@ -1699,3 +1872,3 @@ if (interps) Array.prototype.push.apply(arr, interps);

var options = OPTION_KEYS.reduce(function(obj, key) {
var options = OPTION_KEYS.reduce(function (obj, key) {
obj[key] = DEFAULT_OPTIONS[key];

@@ -1705,5 +1878,5 @@ return obj;

var interpreter = function(input_array, accessor) {
var interpreter = function (input_array, accessor) {
accessor = createAccessorFunction(accessor);
var data = input_array.map(accessor).filter(function(x) { return x; });
var data = input_array.map(accessor).filter(Boolean);
if (!data.length) return include_string ? [string_interpretation] : [];

@@ -1715,28 +1888,31 @@ var n = Math.min(options.n_max, data.length);

var valid_interpreters = interpretations.slice()
.reduce(function(keep, interp, index) {
var n_fail = i = 0;
var failing_values = [];
var complete_failure = false;
var valid_interpreters = interpretations
.slice()
.reduce(function (keep, interp, index) {
var n_fail = (i = 0);
var failing_values = [];
var complete_failure = false;
for (var i = 0; i < n; i++) {
var val = data[i];
var is_valid = interp.test(val);
if (is_valid) continue;
if (++n_fail > n_max_failure) complete_failure = true;
else if (failing_values.indexOf(val) === -1) {
failing_values.push(val);
if (failing_values.length > n_failing_values) complete_failure = true;
for (var i = 0; i < n; i++) {
var val = data[i];
var is_valid = interp.test(val);
if (is_valid) continue;
if (++n_fail > n_max_failure) complete_failure = true;
else if (failing_values.indexOf(val) === -1) {
failing_values.push(val);
if (failing_values.length > n_failing_values)
complete_failure = true;
}
if (complete_failure) break;
}
if (complete_failure) break;
}
if (!complete_failure) keep.push({ interp: interp, n_success: n - n_fail, index: index });
if (!complete_failure)
keep.push({ interp: interp, n_success: n - n_fail, index: index });
return keep;
}, [])
.sort(sortMethod)
.map(function(valid) {
return valid.interp;
});
return keep;
}, [])
.sort(sortMethod)
.map(function (valid) {
return valid.interp;
});

@@ -1748,4 +1924,4 @@ if (include_string) valid_interpreters.push(string_interpretation);

OPTION_KEYS.forEach(function(option) {
interpreter[snakeToCamel(option)] = function(value) {
OPTION_KEYS.forEach(function (option) {
interpreter[snakeToCamel(option)] = function (value) {
if (value === undefined) return options[option];

@@ -1760,10 +1936,26 @@ options[option] = value;

createInterpreter.DATETIME_IDS = Object.freeze(datetime_interpretations.map(function(d) { return d.id; }));
createInterpreter.NUMBER_IDS = Object.freeze(number_interpretations.map(function(d) { return d.id; }));
createInterpreter.DATETIME_IDS = Object.freeze(
datetime_interpretations.map(function (d) {
return d.id;
}),
);
createInterpreter.NUMBER_IDS = Object.freeze(
number_interpretations.map(function (d) {
return d.id;
}),
);
createInterpreter.STRING_IDS = Object.freeze([string_interpretation.id]);
createInterpreter.getInterpretation = (function() {
var interpretations = datetime_interpretations.concat(number_interpretations, string_interpretation);
var lookup = interpretations.reduce(function(l, d) { l[d.id] = d; return l; }, {});
return function(id) { return lookup[id]; };
createInterpreter.getInterpretation = (function () {
var interpretations = datetime_interpretations.concat(
number_interpretations,
string_interpretation,
);
var lookup = interpretations.reduce(function (l, d) {
l[d.id] = d;
return l;
}, {});
return function (id) {
return lookup[id];
};
})();

@@ -1770,0 +1962,0 @@

@@ -1,1 +0,1 @@

(function(e,n){typeof exports==="object"&&typeof module!=="undefined"?n(exports):typeof define==="function"&&define.amd?define(["exports"],n):(e=typeof globalThis!=="undefined"?globalThis:e||self,n(e.createInterpreter={}))})(this,function(e){"use strict";var u=new Date,f=new Date;function c(i,a,t,r){function o(e){return i(e=arguments.length===0?new Date:new Date(+e)),e}o.floor=function(e){return i(e=new Date(+e)),e};o.ceil=function(e){return i(e=new Date(e-1)),a(e,1),i(e),e};o.round=function(e){var n=o(e),t=o.ceil(e);return e-n<t-e?n:t};o.offset=function(e,n){return a(e=new Date(+e),n==null?1:Math.floor(n)),e};o.range=function(e,n,t){var r=[],u;e=o.ceil(e);t=t==null?1:Math.floor(t);if(!(e<n)||!(t>0))return r;do{r.push(u=new Date(+e)),a(e,t),i(e)}while(u<e&&e<n);return r};o.filter=function(t){return c(function(e){if(e>=e)while(i(e),!t(e))e.setTime(e-1)},function(e,n){if(e>=e){if(n<0)while(++n<=0){while(a(e,-1),!t(e)){}}else while(--n>=0){while(a(e,+1),!t(e)){}}}})};if(t){o.count=function(e,n){u.setTime(+e),f.setTime(+n);i(u),i(f);return Math.floor(t(u,f))};o.every=function(n){n=Math.floor(n);return!isFinite(n)||!(n>0)?null:!(n>1)?o:o.filter(r?function(e){return r(e)%n===0}:function(e){return o.count(0,e)%n===0})}}return o}var t=6e4;var S=864e5;var _=6048e5;var H=c(function(e){e.setHours(0,0,0,0)},function(e,n){e.setDate(e.getDate()+n)},function(e,n){return(n-e-(n.getTimezoneOffset()-e.getTimezoneOffset())*t)/S},function(e){return e.getDate()-1});var R=H;H.range;function n(n){return c(function(e){e.setDate(e.getDate()-(e.getDay()+7-n)%7);e.setHours(0,0,0,0)},function(e,n){e.setDate(e.getDate()+n*7)},function(e,n){return(n-e-(n.getTimezoneOffset()-e.getTimezoneOffset())*t)/_})}var j=n(0);var V=n(1);var A=n(2);var k=n(3);var r=n(4);var $=n(5);var z=n(6);j.range;V.range;A.range;k.range;r.range;$.range;z.range;var i=c(function(e){e.setMonth(0,1);e.setHours(0,0,0,0)},function(e,n){e.setFullYear(e.getFullYear()+n)},function(e,n){return n.getFullYear()-e.getFullYear()},function(e){return e.getFullYear()});i.every=function(t){return!isFinite(t=Math.floor(t))||!(t>0)?null:c(function(e){e.setFullYear(Math.floor(e.getFullYear()/t)*t);e.setMonth(0,1);e.setHours(0,0,0,0)},function(e,n){e.setFullYear(e.getFullYear()+n*t)})};var a=i;i.range;var N=c(function(e){e.setUTCHours(0,0,0,0)},function(e,n){e.setUTCDate(e.getUTCDate()+n)},function(e,n){return(n-e)/S},function(e){return e.getUTCDate()-1});var K=N;N.range;function o(n){return c(function(e){e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-n)%7);e.setUTCHours(0,0,0,0)},function(e,n){e.setUTCDate(e.getUTCDate()+n*7)},function(e,n){return(n-e)/_})}var O=o(0);var X=o(1);var L=o(2);var E=o(3);var s=o(4);var I=o(5);var Z=o(6);O.range;X.range;L.range;E.range;s.range;I.range;Z.range;var l=c(function(e){e.setUTCMonth(0,1);e.setUTCHours(0,0,0,0)},function(e,n){e.setUTCFullYear(e.getUTCFullYear()+n)},function(e,n){return n.getUTCFullYear()-e.getUTCFullYear()},function(e){return e.getUTCFullYear()});l.every=function(t){return!isFinite(t=Math.floor(t))||!(t>0)?null:c(function(e){e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t);e.setUTCMonth(0,1);e.setUTCHours(0,0,0,0)},function(e,n){e.setUTCFullYear(e.getUTCFullYear()+n*t)})};var d=l;l.range;function q(e){if(0<=e.y&&e.y<100){var n=new Date(-1,e.m,e.d,e.H,e.M,e.S,e.L);n.setFullYear(e.y);return n}return new Date(e.y,e.m,e.d,e.H,e.M,e.S,e.L)}function Q(e){if(0<=e.y&&e.y<100){var n=new Date(Date.UTC(-1,e.m,e.d,e.H,e.M,e.S,e.L));n.setUTCFullYear(e.y);return n}return new Date(Date.UTC(e.y,e.m,e.d,e.H,e.M,e.S,e.L))}function P(e,n,t){return{y:e,m:n,d:t,H:0,M:0,S:0,L:0}}function B(e){var r=e.dateTime,u=e.date,i=e.time,n=e.periods,t=e.days,a=e.shortDays,o=e.months,f=e.shortMonths;var c=J(n),s=G(n),l=J(t),d=G(t),p=J(a),g=G(a),m=J(o),h=G(o),v=J(f),y=G(f);var M={a:A,A:k,b:$,B:z,c:null,d:Te,e:Te,f:Ue,g:Le,G:Ie,H:xe,I:Fe,j:Ce,L:Ye,m:Se,M:_e,p:N,q:O,Q:ln,s:dn,S:He,u:je,U:Ae,V:$e,w:ze,W:Ne,x:null,X:null,y:Oe,Y:Ee,Z:Ze,"%":sn};var b={a:L,A:E,b:I,B:Z,c:null,d:Be,e:Be,f:Qe,g:an,G:fn,H:We,I:Ve,j:Xe,L:qe,m:Pe,M:Je,p:B,q:W,Q:ln,s:dn,S:Ge,u:Re,U:Ke,V:nn,w:tn,W:rn,x:null,X:null,y:un,Y:on,Z:cn,"%":sn};var D={a:C,A:Y,b:U,B:S,c:_,d:pe,e:pe,f:Me,g:ce,G:fe,H:me,I:me,j:ge,L:ye,m:de,M:he,p:F,q:le,Q:De,s:we,S:ve,u:ue,U:ie,V:ae,w:re,W:oe,x:H,X:j,y:ce,Y:fe,Z:se,"%":be};M.x=w(u,M);M.X=w(i,M);M.c=w(r,M);b.x=w(u,b);b.X=w(i,b);b.c=w(r,b);function w(f,c){return function(e){var n=[],t=-1,r=0,u=f.length,i,a,o;if(!(e instanceof Date))e=new Date(+e);while(++t<u){if(f.charCodeAt(t)===37){n.push(f.slice(r,t));if((a=ee[i=f.charAt(++t)])!=null)i=f.charAt(++t);else a=i==="e"?" ":"0";if(o=c[i])i=o(e,a);n.push(i);r=t+1}}n.push(f.slice(r,t));return n.join("")}}function T(i,a){return function(e){var n=P(1900,undefined,1),t=x(n,i,e+="",0),r,u;if(t!=e.length)return null;if("Q"in n)return new Date(n.Q);if("s"in n)return new Date(n.s*1e3+("L"in n?n.L:0));if(a&&!("Z"in n))n.Z=0;if("p"in n)n.H=n.H%12+n.p*12;if(n.m===undefined)n.m="q"in n?n.q:0;if("V"in n){if(n.V<1||n.V>53)return null;if(!("w"in n))n.w=1;if("Z"in n){r=Q(P(n.y,0,1)),u=r.getUTCDay();r=u>4||u===0?X.ceil(r):X(r);r=K.offset(r,(n.V-1)*7);n.y=r.getUTCFullYear();n.m=r.getUTCMonth();n.d=r.getUTCDate()+(n.w+6)%7}else{r=q(P(n.y,0,1)),u=r.getDay();r=u>4||u===0?V.ceil(r):V(r);r=R.offset(r,(n.V-1)*7);n.y=r.getFullYear();n.m=r.getMonth();n.d=r.getDate()+(n.w+6)%7}}else if("W"in n||"U"in n){if(!("w"in n))n.w="u"in n?n.u%7:"W"in n?1:0;u="Z"in n?Q(P(n.y,0,1)).getUTCDay():q(P(n.y,0,1)).getDay();n.m=0;n.d="W"in n?(n.w+6)%7+n.W*7-(u+5)%7:n.w+n.U*7-(u+6)%7}if("Z"in n){n.H+=n.Z/100|0;n.M+=n.Z%100;return Q(n)}return q(n)}}function x(e,n,t,r){var u=0,i=n.length,a=t.length,o,f;while(u<i){if(r>=a)return-1;o=n.charCodeAt(u++);if(o===37){o=n.charAt(u++);f=D[o in ee?n.charAt(u++):o];if(!f||(r=f(e,t,r))<0)return-1}else if(o!=t.charCodeAt(r++)){return-1}}return r}function F(e,n,t){var r=c.exec(n.slice(t));return r?(e.p=s[r[0].toLowerCase()],t+r[0].length):-1}function C(e,n,t){var r=p.exec(n.slice(t));return r?(e.w=g[r[0].toLowerCase()],t+r[0].length):-1}function Y(e,n,t){var r=l.exec(n.slice(t));return r?(e.w=d[r[0].toLowerCase()],t+r[0].length):-1}function U(e,n,t){var r=v.exec(n.slice(t));return r?(e.m=y[r[0].toLowerCase()],t+r[0].length):-1}function S(e,n,t){var r=m.exec(n.slice(t));return r?(e.m=h[r[0].toLowerCase()],t+r[0].length):-1}function _(e,n,t){return x(e,r,n,t)}function H(e,n,t){return x(e,u,n,t)}function j(e,n,t){return x(e,i,n,t)}function A(e){return a[e.getDay()]}function k(e){return t[e.getDay()]}function $(e){return f[e.getMonth()]}function z(e){return o[e.getMonth()]}function N(e){return n[+(e.getHours()>=12)]}function O(e){return 1+~~(e.getMonth()/3)}function L(e){return a[e.getUTCDay()]}function E(e){return t[e.getUTCDay()]}function I(e){return f[e.getUTCMonth()]}function Z(e){return o[e.getUTCMonth()]}function B(e){return n[+(e.getUTCHours()>=12)]}function W(e){return 1+~~(e.getUTCMonth()/3)}return{format:function(e){var n=w(e+="",M);n.toString=function(){return e};return n},parse:function(e){var n=T(e+="",false);n.toString=function(){return e};return n},utcFormat:function(e){var n=w(e+="",b);n.toString=function(){return e};return n},utcParse:function(e){var n=T(e+="",true);n.toString=function(){return e};return n}}}var ee={"-":"",_:" ",0:"0"},p=/^\s*\d+/,W=/^%/,ne=/[\\^$*+?|[\]().{}]/g;function g(e,n,t){var r=e<0?"-":"",u=(r?-e:e)+"",i=u.length;return r+(i<t?new Array(t-i+1).join(n)+u:u)}function te(e){return e.replace(ne,"\\$&")}function J(e){return new RegExp("^(?:"+e.map(te).join("|")+")","i")}function G(e){var n={},t=-1,r=e.length;while(++t<r)n[e[t].toLowerCase()]=t;return n}function re(e,n,t){var r=p.exec(n.slice(t,t+1));return r?(e.w=+r[0],t+r[0].length):-1}function ue(e,n,t){var r=p.exec(n.slice(t,t+1));return r?(e.u=+r[0],t+r[0].length):-1}function ie(e,n,t){var r=p.exec(n.slice(t,t+2));return r?(e.U=+r[0],t+r[0].length):-1}function ae(e,n,t){var r=p.exec(n.slice(t,t+2));return r?(e.V=+r[0],t+r[0].length):-1}function oe(e,n,t){var r=p.exec(n.slice(t,t+2));return r?(e.W=+r[0],t+r[0].length):-1}function fe(e,n,t){var r=p.exec(n.slice(t,t+4));return r?(e.y=+r[0],t+r[0].length):-1}function ce(e,n,t){var r=p.exec(n.slice(t,t+2));return r?(e.y=+r[0]+(+r[0]>68?1900:2e3),t+r[0].length):-1}function se(e,n,t){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(n.slice(t,t+6));return r?(e.Z=r[1]?0:-(r[2]+(r[3]||"00")),t+r[0].length):-1}function le(e,n,t){var r=p.exec(n.slice(t,t+1));return r?(e.q=r[0]*3-3,t+r[0].length):-1}function de(e,n,t){var r=p.exec(n.slice(t,t+2));return r?(e.m=r[0]-1,t+r[0].length):-1}function pe(e,n,t){var r=p.exec(n.slice(t,t+2));return r?(e.d=+r[0],t+r[0].length):-1}function ge(e,n,t){var r=p.exec(n.slice(t,t+3));return r?(e.m=0,e.d=+r[0],t+r[0].length):-1}function me(e,n,t){var r=p.exec(n.slice(t,t+2));return r?(e.H=+r[0],t+r[0].length):-1}function he(e,n,t){var r=p.exec(n.slice(t,t+2));return r?(e.M=+r[0],t+r[0].length):-1}function ve(e,n,t){var r=p.exec(n.slice(t,t+2));return r?(e.S=+r[0],t+r[0].length):-1}function ye(e,n,t){var r=p.exec(n.slice(t,t+3));return r?(e.L=+r[0],t+r[0].length):-1}function Me(e,n,t){var r=p.exec(n.slice(t,t+6));return r?(e.L=Math.floor(r[0]/1e3),t+r[0].length):-1}function be(e,n,t){var r=W.exec(n.slice(t,t+1));return r?t+r[0].length:-1}function De(e,n,t){var r=p.exec(n.slice(t));return r?(e.Q=+r[0],t+r[0].length):-1}function we(e,n,t){var r=p.exec(n.slice(t));return r?(e.s=+r[0],t+r[0].length):-1}function Te(e,n){return g(e.getDate(),n,2)}function xe(e,n){return g(e.getHours(),n,2)}function Fe(e,n){return g(e.getHours()%12||12,n,2)}function Ce(e,n){return g(1+R.count(a(e),e),n,3)}function Ye(e,n){return g(e.getMilliseconds(),n,3)}function Ue(e,n){return Ye(e,n)+"000"}function Se(e,n){return g(e.getMonth()+1,n,2)}function _e(e,n){return g(e.getMinutes(),n,2)}function He(e,n){return g(e.getSeconds(),n,2)}function je(e){var n=e.getDay();return n===0?7:n}function Ae(e,n){return g(j.count(a(e)-1,e),n,2)}function ke(e){var n=e.getDay();return n>=4||n===0?r(e):r.ceil(e)}function $e(e,n){e=ke(e);return g(r.count(a(e),e)+(a(e).getDay()===4),n,2)}function ze(e){return e.getDay()}function Ne(e,n){return g(V.count(a(e)-1,e),n,2)}function Oe(e,n){return g(e.getFullYear()%100,n,2)}function Le(e,n){e=ke(e);return g(e.getFullYear()%100,n,2)}function Ee(e,n){return g(e.getFullYear()%1e4,n,4)}function Ie(e,n){var t=e.getDay();e=t>=4||t===0?r(e):r.ceil(e);return g(e.getFullYear()%1e4,n,4)}function Ze(e){var n=e.getTimezoneOffset();return(n>0?"-":(n*=-1,"+"))+g(n/60|0,"0",2)+g(n%60,"0",2)}function Be(e,n){return g(e.getUTCDate(),n,2)}function We(e,n){return g(e.getUTCHours(),n,2)}function Ve(e,n){return g(e.getUTCHours()%12||12,n,2)}function Xe(e,n){return g(1+K.count(d(e),e),n,3)}function qe(e,n){return g(e.getUTCMilliseconds(),n,3)}function Qe(e,n){return qe(e,n)+"000"}function Pe(e,n){return g(e.getUTCMonth()+1,n,2)}function Je(e,n){return g(e.getUTCMinutes(),n,2)}function Ge(e,n){return g(e.getUTCSeconds(),n,2)}function Re(e){var n=e.getUTCDay();return n===0?7:n}function Ke(e,n){return g(O.count(d(e)-1,e),n,2)}function en(e){var n=e.getUTCDay();return n>=4||n===0?s(e):s.ceil(e)}function nn(e,n){e=en(e);return g(s.count(d(e),e)+(d(e).getUTCDay()===4),n,2)}function tn(e){return e.getUTCDay()}function rn(e,n){return g(X.count(d(e)-1,e),n,2)}function un(e,n){return g(e.getUTCFullYear()%100,n,2)}function an(e,n){e=en(e);return g(e.getUTCFullYear()%100,n,2)}function on(e,n){return g(e.getUTCFullYear()%1e4,n,4)}function fn(e,n){var t=e.getUTCDay();e=t>=4||t===0?s(e):s.ceil(e);return g(e.getUTCFullYear()%1e4,n,4)}function cn(){return"+0000"}function sn(){return"%"}function ln(e){return+e}function dn(e){return Math.floor(+e/1e3)}var m;var pn;var gn;mn({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function mn(e){m=B(e);m.format;m.parse;pn=m.utcFormat;gn=m.utcParse;return m}function h(e){throw new TypeError("Expected a value of type string but got a value of type "+typeof e)}function v(n){return function(e){if(typeof e!=="string")h(e);e=e.trim();return e?n(e):null}}var hn=new Date(1972,3,27,19,45,5);var y={"%b %d":[{regex:/^june\s(30|[12][0-9]|0?[1-9])$/i,toDate:function(e){return new Date(null,5,e.split(/\s/)[1])}},{regex:/^july\s(3[01]|[12][0-9]|0?[1-9])$/i,toDate:function(e){return new Date(null,6,e.split(/\s/)[1])}},{regex:/^sept\s(30|[12][0-9]|0?[1-9])$/i,toDate:function(e){return new Date(null,8,e.split(/\s/)[1])}}],"%d %b":[{regex:/^(0?[1-9]|[1-9][0-9])\sjune$/i,toDate:function(e){return new Date(null,5,e.split(/\s/)[0])}},{regex:/^(0?[1-9]|[1-9][0-9])\sjuly$/i,toDate:function(e){return new Date(null,6,e.split(/\s/)[0])}},{regex:/^(0?[1-9]|[1-9][0-9])\ssept$/i,toDate:function(e){return new Date(null,8,e.split(/\s/)[0])}}]};function M(e){return function(t){var r=null;e.forEach(function(e){var n=t.match(e.regex);if(n)r=e.toDate(t)});return r}}function b(n,t){var r=gn(n);var u=pn(n);var e;if(typeof t==="function"){e=v(function(e){return t(e,r(e)!==null)})}else{e=v(function(e){return r(e)!==null})}return Object.freeze({test:e,parse:v(function(e){return r(e)||(y[n]?M(y[n])(e):null)}),format:function(e){return u(e)},type:"datetime",description:n,id:"datetime$"+n,example:u(hn)})}var D=Object.freeze([b("%Y-%m-%dT%H:%M:%S.%LZ"),b("%Y-%m-%d %H:%M:%S"),b("%Y-%m-%dT%H:%M:%S"),b("%Y-%m-%dT%H:%M:%SZ"),b("%d/%m/%Y",function(e,n){if(!n)return false;var t=e.split("/").map(parseFloat);return t[0]>0&&t[0]<=31&&(t[1]>0&&t[1]<=12)&&t[2]>=1e3}),b("%d/%m/%Y %H:%M",function(e,n){if(!n)return false;var t=e.split(/[/ :]/).map(parseFloat);return t[0]>0&&t[0]<=31&&(t[1]>0&&t[1]<=12)&&t[2]>=1e3&&(t[3]>=0&&t[3]<24)&&(t[4]>=0&&t[4]<60)}),b("%d/%m/%y",function(e,n){if(!n)return false;var t=e.split("/").map(parseFloat);return t[0]>0&&t[0]<=31&&(t[1]>0&&t[1]<=12)&&!isNaN(t[2])}),b("%m/%d/%Y",function(e,n){if(!n)return false;var t=e.split("/").map(parseFloat);return t[0]>0&&t[0]<=12&&(t[1]>0&&t[1]<=31)&&t[2]>=1e3}),b("%m/%d/%Y %H:%M",function(e,n){if(!n)return false;var t=e.split(/[/ :]/).map(parseFloat);return t[0]>0&&t[0]<=12&&(t[1]>0&&t[1]<=31)&&t[2]>=1e3&&(t[3]>=0&&t[3]<24)&&(t[4]>=0&&t[4]<60)}),b("%m/%d/%y",function(e,n){if(!n)return false;var t=e.split("/").map(parseFloat);return t[0]>0&&t[0]<=12&&(t[1]>0&&t[1]<=31)&&!isNaN(t[2])}),b("%Y/%m/%d",function(e,n){if(!n)return false;var t=e.split("/").map(parseFloat);return t[0]>=1e3&&(t[1]>0&&t[1]<=12)&&(t[2]>0&&t[2]<=31)}),b("%d-%m-%Y",function(e,n){if(!n)return false;var t=e.split("-").map(parseFloat);return t[0]>0&&t[0]<=31&&(t[1]>0&&t[1]<=12)&&t[2]>=1e3}),b("%d-%m-%y",function(e,n){if(!n)return false;var t=e.split("-").map(parseFloat);return t[0]>0&&t[0]<=31&&(t[1]>0&&t[1]<=12)&&!isNaN(t[2])}),b("%d.%m.%Y",function(e,n){if(!n)return false;var t=e.split(".").map(parseFloat);return t[0]>0&&t[0]<=31&&(t[1]>0&&t[1]<=12)&&t[2]>=1e3}),b("%m.%d.%y",function(e,n){if(!n)return false;var t=e.split(".").map(parseFloat);return t[0]>0&&t[0]<=12&&(t[1]>0&&t[1]<=31)&&!isNaN(t[2])}),b("%m-%d-%Y",function(e,n){if(!n)return false;var t=e.split("-").map(parseFloat);return t[0]>0&&t[0]<=12&&(t[1]>0&&t[1]<=31)&&t[2]>=1e3}),b("%m-%d-%y",function(e,n){if(!n)return false;var t=e.split("-").map(parseFloat);return t[0]>0&&t[0]<=12&&(t[1]>0&&t[1]<=31)&&!isNaN(t[2])}),b("%Y-%m-%d",function(e,n){if(!n)return false;var t=e.split("-").map(parseFloat);return t[0]>=1e3&&(t[1]>0&&t[1]<=12)&&(t[2]>0&&t[2]<=31)}),b("%Y-%m",function(e,n){if(!n)return false;var t=e.split("-").map(parseFloat);return t[0]>=1e3&&(t[1]>0&&t[1]<=12)}),b("%Y%m",function(e,n){if(!n)return false;var t=parseFloat(e.slice(0,4));var r=parseFloat(e.slice(4));return t>1e3&&r>0&&r<=12}),b("%d %b %Y",function(e,n){if(!n)return false;var t=e.split(" ").map(parseFloat);return t[0]>0&&t[0]<=31&&t[2]>=1e3}),b("%d %B %Y",function(e,n){if(!n)return false;var t=e.split(" ").map(parseFloat);return t[0]>0&&t[0]<=31&&t[2]>=1e3}),b("%d %b %y"),b("%-d %b ’%y"),b("%d %B %y"),b("%d-%b-%Y",function(e,n){if(!n)return false;var t=e.split("-").map(parseFloat);return t[0]>0&&t[0]<=31&&t[2]>=1e3}),b("%d-%B-%Y",function(e,n){if(!n)return false;var t=e.split("-").map(parseFloat);return t[0]>0&&t[0]<=31&&t[2]>=1e3}),b("%d-%b-%y"),b("%d-%B-%y"),b("%m/%Y",function(e,n){if(!n)return false;var t=e.split("/").map(parseFloat);return t[0]>0&&t[0]<=12&&t[1]>=1e3}),b("%m/%y"),b("%b %Y",function(e,n){if(!n)return false;var t=e.split(" ").map(parseFloat);return t[1]>=1e3}),b("%B %Y",function(e,n){if(!n)return false;var t=e.split(" ").map(parseFloat);return t[1]>=1e3}),b("%b-%y"),b("%b %y"),b("%B %y"),b("%b '%y"),b("%b ’%y"),b("%B %-d %Y"),b("%d %b",function(e,n){if(n)return true;return!!M(y["%d %b"])(e)}),b("%d %B"),b("%b %d",function(e,n){if(n)return true;return!!M(y["%b %d"])(e)}),b("%B %d"),b("%d-%m",function(e,n){if(!n)return false;var t=e.split("-").map(parseFloat);return t[0]>0&&t[0]<=31&&(t[1]>0&&t[1]<=12)}),b("%m-%d"),b("%d/%m"),b("%m/%d"),b("%b %d %Y"),b("%b %d %Y, %-I.%M%p"),b("%Y",function(e,n){if(!n)return false;var t=parseFloat(e);return t>1499&&t<2200}),b("%B"),b("%b"),b("%X"),b("%I:%M %p"),b("%-I.%M%p"),b("%H:%M",function(e,n){if(!n)return false;var t=e.split(":").map(parseFloat);return t[0]>=0&&t[0]<24}),b("%H:%M:%S"),b("%M:%S"),b("%-I%p"),b("Q%q %Y",function(e,n){if(!n)return false;return e.replace(/\s/g,"").length===6}),b("%Y Q%q",function(e,n){if(!n)return false;return e.replace(/\s/g,"").length===6})]);function vn(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function w(e,n){if((t=(e=n?e.toExponential(n-1):e.toExponential()).indexOf("e"))<0)return null;var t,r=e.slice(0,t);return[r.length>1?r[0]+r.slice(2):r,+e.slice(t+1)]}function yn(e){return e=w(Math.abs(e)),e?e[1]:NaN}function Mn(o,f){return function(e,n){var t=e.length,r=[],u=0,i=o[0],a=0;while(t>0&&i>0){if(a+i+1>n)i=Math.max(1,n-a);r.push(e.substring(t-=i,t+i));if((a+=i+1)>n)break;i=o[u=(u+1)%o.length]}return r.reverse().join(f)}}function bn(n){return function(e){return e.replace(/[0-9]/g,function(e){return n[+e]})}}var Dn=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Y(e){if(!(n=Dn.exec(e)))throw new Error("invalid format: "+e);var n;return new T({fill:n[1],align:n[2],sign:n[3],symbol:n[4],zero:n[5],width:n[6],comma:n[7],precision:n[8]&&n[8].slice(1),trim:n[9],type:n[10]})}Y.prototype=T.prototype;function T(e){this.fill=e.fill===undefined?" ":e.fill+"";this.align=e.align===undefined?">":e.align+"";this.sign=e.sign===undefined?"-":e.sign+"";this.symbol=e.symbol===undefined?"":e.symbol+"";this.zero=!!e.zero;this.width=e.width===undefined?undefined:+e.width;this.comma=!!e.comma;this.precision=e.precision===undefined?undefined:+e.precision;this.trim=!!e.trim;this.type=e.type===undefined?"":e.type+""}T.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===undefined?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===undefined?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function wn(e){e:for(var n=e.length,t=1,r=-1,u;t<n;++t){switch(e[t]){case".":r=u=t;break;case"0":if(r===0)r=t;u=t;break;default:if(!+e[t])break e;if(r>0)r=0;break}}return r>0?e.slice(0,r)+e.slice(u+1):e}var Tn;function xn(e,n){var t=w(e,n);if(!t)return e+"";var r=t[0],u=t[1],i=u-(Tn=Math.max(-8,Math.min(8,Math.floor(u/3)))*3)+1,a=r.length;return i===a?r:i>a?r+new Array(i-a+1).join("0"):i>0?r.slice(0,i)+"."+r.slice(i):"0."+new Array(1-i).join("0")+w(e,Math.max(0,n+i-1))[0]}function Fn(e,n){var t=w(e,n);if(!t)return e+"";var r=t[0],u=t[1];return u<0?"0."+new Array(-u).join("0")+r:r.length>u+1?r.slice(0,u+1)+"."+r.slice(u+1):r+new Array(u-r.length+2).join("0")}var Cn={"%":function(e,n){return(e*100).toFixed(n)},b:function(e){return Math.round(e).toString(2)},c:function(e){return e+""},d:vn,e:function(e,n){return e.toExponential(n)},f:function(e,n){return e.toFixed(n)},g:function(e,n){return e.toPrecision(n)},o:function(e){return Math.round(e).toString(8)},p:function(e,n){return Fn(e*100,n)},r:Fn,s:xn,X:function(e){return Math.round(e).toString(16).toUpperCase()},x:function(e){return Math.round(e).toString(16)}};function Yn(e){return e}var Un=Array.prototype.map,Sn=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function _n(e){var w=e.grouping===undefined||e.thousands===undefined?Yn:Mn(Un.call(e.grouping,Number),e.thousands+""),r=e.currency===undefined?"":e.currency[0]+"",u=e.currency===undefined?"":e.currency[1]+"",T=e.decimal===undefined?".":e.decimal+"",x=e.numerals===undefined?Yn:bn(Un.call(e.numerals,String)),i=e.percent===undefined?"%":e.percent+"",F=e.minus===undefined?"-":e.minus+"",C=e.nan===undefined?"NaN":e.nan+"";function a(e){e=Y(e);var c=e.fill,s=e.align,l=e.sign,n=e.symbol,d=e.zero,p=e.width,g=e.comma,m=e.precision,h=e.trim,v=e.type;if(v==="n")g=true,v="g";else if(!Cn[v])m===undefined&&(m=12),h=true,v="g";if(d||c==="0"&&s==="=")d=true,c="0",s="=";var y=n==="$"?r:n==="#"&&/[boxX]/.test(v)?"0"+v.toLowerCase():"",M=n==="$"?u:/[%p]/.test(v)?i:"";var b=Cn[v],D=/[defgprs%]/.test(v);m=m===undefined?6:/[gprs]/.test(v)?Math.max(1,Math.min(21,m)):Math.max(0,Math.min(20,m));function t(e){var n=y,t=M,r,u,i;if(v==="c"){t=b(e)+t;e=""}else{e=+e;var a=e<0||1/e<0;e=isNaN(e)?C:b(Math.abs(e),m);if(h)e=wn(e);if(a&&+e===0&&l!=="+")a=false;n=(a?l==="("?l:F:l==="-"||l==="("?"":l)+n;t=(v==="s"?Sn[8+Tn/3]:"")+t+(a&&l==="("?")":"");if(D){r=-1,u=e.length;while(++r<u){if(i=e.charCodeAt(r),48>i||i>57){t=(i===46?T+e.slice(r+1):e.slice(r))+t;e=e.slice(0,r);break}}}}if(g&&!d)e=w(e,Infinity);var o=n.length+e.length+t.length,f=o<p?new Array(p-o+1).join(c):"";if(g&&d)e=w(f+e,f.length?p-t.length:Infinity),f="";switch(s){case"<":e=n+e+t+f;break;case"=":e=n+f+e+t;break;case"^":e=f.slice(0,o=f.length>>1)+n+e+t+f.slice(o);break;default:e=f+n+e+t;break}return x(e)}t.toString=function(){return e+""};return t}function n(e,n){var t=a((e=Y(e),e.type="f",e)),r=Math.max(-8,Math.min(8,Math.floor(yn(n)/3)))*3,u=Math.pow(10,-r),i=Sn[8+r/3];return function(e){return t(u*e)+i}}return{format:a,formatPrefix:n}}function Hn(e){var n=e.decimal_mark;var t=e.thousand_separator;var r=_n({decimal:n,thousands:t,grouping:[3],currency:["",""]});var u,i;return function(e,n){if(e===null)return"";if(!n)n=",.2f";if(n!==i){i=n;u=r.format(i)}return u(e)}}var jn={test:v(function(e){return/^(\+|-)?\d{1,3}(,\d{3})*(\.\d+)?((e|E)(\+|-)?\d+)?$/.test(e.trim())}),parse:v(function(e){return parseFloat(e.replace(/,/g,""))}),description:"Comma thousand separator, point decimal mark",thousand_separator:",",decimal_mark:".",id:"number$comma_point",example:"12,235.56"};var An={test:v(function(e){return/^(\+|-)?\d{1,3}(\s\d{3})*(\.\d+)?((e|E)(\+|-)?\d+)?$/.test(e.trim())}),parse:v(function(e){return parseFloat(e.replace(/\s/g,""))}),description:"Space thousand separator, point decimal mark",thousand_separator:" ",decimal_mark:".",id:"number$space_point",example:"12 235.56"};var kn={test:v(function(e){return/^(\+|-)?\d+(\.\d+)?((e|E)(\+|-)?\d+)?$/.test(e.trim())}),parse:v(function(e){return parseFloat(e)}),description:"No thousand separator, point decimal mark",thousand_separator:"",decimal_mark:".",id:"number$none_point",example:"12235.56"};var $n={test:v(function(e){return/^(\+|-)?\d{1,3}(\.\d{3})*(,\d+)?((e|E)(\+|-)?\d+)?$/.test(e.trim())}),parse:v(function(e){return parseFloat(e.replace(/\./g,"").replace(/,/,"."))}),description:"Point thousand separator, comma decimal mark",thousand_separator:".",decimal_mark:",",id:"number$point_comma",example:"12.235,56"};var zn={test:v(function(e){return/^(\+|-)?\d{1,3}(\s\d{3})*(,\d+)?((e|E)(\+|-)?\d+)?$/.test(e.trim())}),parse:v(function(e){return parseFloat(e.replace(/\s/g,"").replace(/,/,"."))}),description:"Space thousand separator, comma decimal mark",thousand_separator:" ",decimal_mark:",",id:"number$space_comma",example:"12 235,56"};var Nn={test:v(function(e){return/^(\+|-)?\d+(,\d+)?((e|E)(\+|-)?\d+)?$/.test(e.trim())}),parse:v(function(e){return parseFloat(e.replace(/,/,"."))}),description:"No thousand separator, comma decimal mark",thousand_separator:"",decimal_mark:",",id:"number$none_comma",example:"12235,56"};var x=Object.freeze([jn,An,$n,zn,kn,Nn]);x.forEach(function(e){e.type="number";e.format=Hn(e);Object.freeze(e)});var F=Object.freeze({test:function(e){return typeof e==="string"?true:h(e)},parse:function(e){return typeof e==="string"?e:h(e)},format:function(e){if(typeof e==="string")return e},type:"string",description:"Arbitrary string",id:"string$arbitrary_string"});var On=Object.freeze({datetime:D,number:x});var Ln=Object.freeze(["datetime","number","string"]);var En=Object.freeze({n_max:250,n_failing_values:0,failure_fraction:5/100,sort:true});var In=Object.freeze(Object.keys(En));function Zn(e){return e.replace(/_(\w)/g,function(e,n){return n.toUpperCase()})}function Bn(e,n){return e.index-n.index}function Wn(e,n){return n.n_success-e.n_success||Bn(e,n)}function C(e){return(""+e).trim()}function Vn(t){if(t===undefined)return function(e){return C(e)};if(typeof t==="function")return function(e,n){return C(t(e,n))};return function(e){return C(e[""+t])}}function U(e){if(!e)e=Ln;else if(!Array.isArray(e))e=[e];var u=e.reduce(function(e,n){var t=On[n];if(t)Array.prototype.push.apply(e,t);return e},[]);var i=e.indexOf("string")!==-1;var a=In.reduce(function(e,n){e[n]=En[n];return e},{});var t=function(e,n){n=Vn(n);var c=e.map(n).filter(function(e){return e});if(!c.length)return i?[F]:[];var s=Math.min(a.n_max,c.length);var l=Math.floor(s*a.failure_fraction);var d=a.n_failing_values;var t=a.sort?Wn:Bn;var r=u.slice().reduce(function(e,n,t){var r=a=0;var u=[];var i=false;for(var a=0;a<s;a++){var o=c[a];var f=n.test(o);if(f)continue;if(++r>l)i=true;else if(u.indexOf(o)===-1){u.push(o);if(u.length>d)i=true}if(i)break}if(!i)e.push({interp:n,n_success:s-r,index:t});return e},[]).sort(t).map(function(e){return e.interp});if(i)r.push(F);return r};In.forEach(function(n){t[Zn(n)]=function(e){if(e===undefined)return a[n];a[n]=e;return t}});return t}U.DATETIME_IDS=Object.freeze(D.map(function(e){return e.id}));U.NUMBER_IDS=Object.freeze(x.map(function(e){return e.id}));U.STRING_IDS=Object.freeze([F.id]);U.getInterpretation=function(){var e=D.concat(x,F);var n=e.reduce(function(e,n){e[n.id]=n;return e},{});return function(e){return n[e]}}();U._createAccessorFunction=Vn;var Xn=On;e.createInterpreter=U;e.recognised_formats=Xn});
(function(e,n){typeof exports==="object"&&typeof module!=="undefined"?n(exports):typeof define==="function"&&define.amd?define(["exports"],n):(e=typeof globalThis!=="undefined"?globalThis:e||self,n(e.createInterpreter={}))})(this,function(e){"use strict";var u=new Date,f=new Date;function c(i,a,t,r){function o(e){return i(e=arguments.length===0?new Date:new Date(+e)),e}o.floor=function(e){return i(e=new Date(+e)),e};o.ceil=function(e){return i(e=new Date(e-1)),a(e,1),i(e),e};o.round=function(e){var n=o(e),t=o.ceil(e);return e-n<t-e?n:t};o.offset=function(e,n){return a(e=new Date(+e),n==null?1:Math.floor(n)),e};o.range=function(e,n,t){var r=[],u;e=o.ceil(e);t=t==null?1:Math.floor(t);if(!(e<n)||!(t>0))return r;do{r.push(u=new Date(+e)),a(e,t),i(e)}while(u<e&&e<n);return r};o.filter=function(t){return c(function(e){if(e>=e)while(i(e),!t(e))e.setTime(e-1)},function(e,n){if(e>=e){if(n<0)while(++n<=0){while(a(e,-1),!t(e)){}}else while(--n>=0){while(a(e,+1),!t(e)){}}}})};if(t){o.count=function(e,n){u.setTime(+e),f.setTime(+n);i(u),i(f);return Math.floor(t(u,f))};o.every=function(n){n=Math.floor(n);return!isFinite(n)||!(n>0)?null:!(n>1)?o:o.filter(r?function(e){return r(e)%n===0}:function(e){return o.count(0,e)%n===0})}}return o}var t=6e4;var C=864e5;var U=6048e5;var Q=c(function(e){e.setHours(0,0,0,0)},function(e,n){e.setDate(e.getDate()+n)},function(e,n){return(n-e-(n.getTimezoneOffset()-e.getTimezoneOffset())*t)/C},function(e){return e.getDate()-1});Q.range;function n(n){return c(function(e){e.setDate(e.getDate()-(e.getDay()+7-n)%7);e.setHours(0,0,0,0)},function(e,n){e.setDate(e.getDate()+n*7)},function(e,n){return(n-e-(n.getTimezoneOffset()-e.getTimezoneOffset())*t)/U})}var S=n(0);var W=n(1);var _=n(2);var H=n(3);var r=n(4);var j=n(5);var A=n(6);S.range;W.range;_.range;H.range;r.range;j.range;A.range;var i=c(function(e){e.setMonth(0,1);e.setHours(0,0,0,0)},function(e,n){e.setFullYear(e.getFullYear()+n)},function(e,n){return n.getFullYear()-e.getFullYear()},function(e){return e.getFullYear()});i.every=function(t){return!isFinite(t=Math.floor(t))||!(t>0)?null:c(function(e){e.setFullYear(Math.floor(e.getFullYear()/t)*t);e.setMonth(0,1);e.setHours(0,0,0,0)},function(e,n){e.setFullYear(e.getFullYear()+n*t)})};i.range;var V=c(function(e){e.setUTCHours(0,0,0,0)},function(e,n){e.setUTCDate(e.getUTCDate()+n)},function(e,n){return(n-e)/C},function(e){return e.getUTCDate()-1});V.range;function a(n){return c(function(e){e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-n)%7);e.setUTCHours(0,0,0,0)},function(e,n){e.setUTCDate(e.getUTCDate()+n*7)},function(e,n){return(n-e)/U})}var k=a(0);var X=a(1);var $=a(2);var z=a(3);var o=a(4);var N=a(5);var O=a(6);k.range;X.range;$.range;z.range;o.range;N.range;O.range;var s=c(function(e){e.setUTCMonth(0,1);e.setUTCHours(0,0,0,0)},function(e,n){e.setUTCFullYear(e.getUTCFullYear()+n)},function(e,n){return n.getUTCFullYear()-e.getUTCFullYear()},function(e){return e.getUTCFullYear()});s.every=function(t){return!isFinite(t=Math.floor(t))||!(t>0)?null:c(function(e){e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t);e.setUTCMonth(0,1);e.setUTCHours(0,0,0,0)},function(e,n){e.setUTCFullYear(e.getUTCFullYear()+n*t)})};s.range;function P(e){if(0<=e.y&&e.y<100){var n=new Date(-1,e.m,e.d,e.H,e.M,e.S,e.L);n.setFullYear(e.y);return n}return new Date(e.y,e.m,e.d,e.H,e.M,e.S,e.L)}function J(e){if(0<=e.y&&e.y<100){var n=new Date(Date.UTC(-1,e.m,e.d,e.H,e.M,e.S,e.L));n.setUTCFullYear(e.y);return n}return new Date(Date.UTC(e.y,e.m,e.d,e.H,e.M,e.S,e.L))}function G(e,n,t){return{y:e,m:n,d:t,H:0,M:0,S:0,L:0}}function L(e){var r=e.dateTime,u=e.date,i=e.time,n=e.periods,t=e.days,a=e.shortDays,o=e.months,f=e.shortMonths;var c=R(n),s=K(n),l=R(t),p=K(t),d=R(a),g=K(a),m=R(o),h=K(o),v=R(f),y=K(f);var M={a:A,A:k,b:$,B:z,c:null,d:De,e:De,f:Ce,g:ze,G:Oe,H:Fe,I:we,j:Te,L:xe,m:Ye,M:Ue,p:N,q:O,Q:on,s:fn,S:Se,u:_e,U:He,V:je,w:Ae,W:ke,x:null,X:null,y:$e,Y:Ne,Z:Le,"%":an};var b={a:L,A:E,b:I,B:B,c:null,d:Ee,e:Ee,f:Qe,g:nn,G:rn,H:Ie,I:Be,j:Ze,L:qe,m:We,M:Ve,p:Z,q:q,Q:on,s:fn,S:Xe,u:Pe,U:Je,V:Ge,w:Re,W:Ke,x:null,X:null,y:en,Y:tn,Z:un,"%":an};var D={a:C,A:Y,b:U,B:S,c:_,d:le,e:le,f:ve,g:oe,G:ae,H:de,I:de,j:pe,L:he,m:se,M:ge,p:x,q:ce,Q:Me,s:be,S:me,u:te,U:re,V:ue,w:ne,W:ie,x:H,X:j,y:oe,Y:ae,Z:fe,"%":ye};M.x=F(u,M);M.X=F(i,M);M.c=F(r,M);b.x=F(u,b);b.X=F(i,b);b.c=F(r,b);function F(f,c){return function(e){var n=[],t=-1,r=0,u=f.length,i,a,o;if(!(e instanceof Date))e=new Date(+e);while(++t<u){if(f.charCodeAt(t)===37){n.push(f.slice(r,t));if((a=ee[i=f.charAt(++t)])!=null)i=f.charAt(++t);else a=i==="e"?" ":"0";if(o=c[i])i=o(e,a);n.push(i);r=t+1}}n.push(f.slice(r,t));return n.join("")}}function w(i,a){return function(e){var n=G(1900,undefined,1),t=T(n,i,e+="",0),r,u;if(t!=e.length)return null;if("Q"in n)return new Date(n.Q);if("s"in n)return new Date(n.s*1e3+("L"in n?n.L:0));if(a&&!("Z"in n))n.Z=0;if("p"in n)n.H=n.H%12+n.p*12;if(n.m===undefined)n.m="q"in n?n.q:0;if("V"in n){if(n.V<1||n.V>53)return null;if(!("w"in n))n.w=1;if("Z"in n){r=J(G(n.y,0,1)),u=r.getUTCDay();r=u>4||u===0?X.ceil(r):X(r);r=V.offset(r,(n.V-1)*7);n.y=r.getUTCFullYear();n.m=r.getUTCMonth();n.d=r.getUTCDate()+(n.w+6)%7}else{r=P(G(n.y,0,1)),u=r.getDay();r=u>4||u===0?W.ceil(r):W(r);r=Q.offset(r,(n.V-1)*7);n.y=r.getFullYear();n.m=r.getMonth();n.d=r.getDate()+(n.w+6)%7}}else if("W"in n||"U"in n){if(!("w"in n))n.w="u"in n?n.u%7:"W"in n?1:0;u="Z"in n?J(G(n.y,0,1)).getUTCDay():P(G(n.y,0,1)).getDay();n.m=0;n.d="W"in n?(n.w+6)%7+n.W*7-(u+5)%7:n.w+n.U*7-(u+6)%7}if("Z"in n){n.H+=n.Z/100|0;n.M+=n.Z%100;return J(n)}return P(n)}}function T(e,n,t,r){var u=0,i=n.length,a=t.length,o,f;while(u<i){if(r>=a)return-1;o=n.charCodeAt(u++);if(o===37){o=n.charAt(u++);f=D[o in ee?n.charAt(u++):o];if(!f||(r=f(e,t,r))<0)return-1}else if(o!=t.charCodeAt(r++)){return-1}}return r}function x(e,n,t){var r=c.exec(n.slice(t));return r?(e.p=s[r[0].toLowerCase()],t+r[0].length):-1}function C(e,n,t){var r=d.exec(n.slice(t));return r?(e.w=g[r[0].toLowerCase()],t+r[0].length):-1}function Y(e,n,t){var r=l.exec(n.slice(t));return r?(e.w=p[r[0].toLowerCase()],t+r[0].length):-1}function U(e,n,t){var r=v.exec(n.slice(t));return r?(e.m=y[r[0].toLowerCase()],t+r[0].length):-1}function S(e,n,t){var r=m.exec(n.slice(t));return r?(e.m=h[r[0].toLowerCase()],t+r[0].length):-1}function _(e,n,t){return T(e,r,n,t)}function H(e,n,t){return T(e,u,n,t)}function j(e,n,t){return T(e,i,n,t)}function A(e){return a[e.getDay()]}function k(e){return t[e.getDay()]}function $(e){return f[e.getMonth()]}function z(e){return o[e.getMonth()]}function N(e){return n[+(e.getHours()>=12)]}function O(e){return 1+~~(e.getMonth()/3)}function L(e){return a[e.getUTCDay()]}function E(e){return t[e.getUTCDay()]}function I(e){return f[e.getUTCMonth()]}function B(e){return o[e.getUTCMonth()]}function Z(e){return n[+(e.getUTCHours()>=12)]}function q(e){return 1+~~(e.getUTCMonth()/3)}return{format:function(e){var n=F(e+="",M);n.toString=function(){return e};return n},parse:function(e){var n=w(e+="",false);n.toString=function(){return e};return n},utcFormat:function(e){var n=F(e+="",b);n.toString=function(){return e};return n},utcParse:function(e){var n=w(e+="",true);n.toString=function(){return e};return n}}}var ee={"-":"",_:" ",0:"0"},l=/^\s*\d+/,E=/^%/,I=/[\\^$*+?|[\]().{}]/g;function p(e,n,t){var r=e<0?"-":"",u=(r?-e:e)+"",i=u.length;return r+(i<t?new Array(t-i+1).join(n)+u:u)}function B(e){return e.replace(I,"\\$&")}function R(e){return new RegExp("^(?:"+e.map(B).join("|")+")","i")}function K(e){var n={},t=-1,r=e.length;while(++t<r)n[e[t].toLowerCase()]=t;return n}function ne(e,n,t){var r=l.exec(n.slice(t,t+1));return r?(e.w=+r[0],t+r[0].length):-1}function te(e,n,t){var r=l.exec(n.slice(t,t+1));return r?(e.u=+r[0],t+r[0].length):-1}function re(e,n,t){var r=l.exec(n.slice(t,t+2));return r?(e.U=+r[0],t+r[0].length):-1}function ue(e,n,t){var r=l.exec(n.slice(t,t+2));return r?(e.V=+r[0],t+r[0].length):-1}function ie(e,n,t){var r=l.exec(n.slice(t,t+2));return r?(e.W=+r[0],t+r[0].length):-1}function ae(e,n,t){var r=l.exec(n.slice(t,t+4));return r?(e.y=+r[0],t+r[0].length):-1}function oe(e,n,t){var r=l.exec(n.slice(t,t+2));return r?(e.y=+r[0]+(+r[0]>68?1900:2e3),t+r[0].length):-1}function fe(e,n,t){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(n.slice(t,t+6));return r?(e.Z=r[1]?0:-(r[2]+(r[3]||"00")),t+r[0].length):-1}function ce(e,n,t){var r=l.exec(n.slice(t,t+1));return r?(e.q=r[0]*3-3,t+r[0].length):-1}function se(e,n,t){var r=l.exec(n.slice(t,t+2));return r?(e.m=r[0]-1,t+r[0].length):-1}function le(e,n,t){var r=l.exec(n.slice(t,t+2));return r?(e.d=+r[0],t+r[0].length):-1}function pe(e,n,t){var r=l.exec(n.slice(t,t+3));return r?(e.m=0,e.d=+r[0],t+r[0].length):-1}function de(e,n,t){var r=l.exec(n.slice(t,t+2));return r?(e.H=+r[0],t+r[0].length):-1}function ge(e,n,t){var r=l.exec(n.slice(t,t+2));return r?(e.M=+r[0],t+r[0].length):-1}function me(e,n,t){var r=l.exec(n.slice(t,t+2));return r?(e.S=+r[0],t+r[0].length):-1}function he(e,n,t){var r=l.exec(n.slice(t,t+3));return r?(e.L=+r[0],t+r[0].length):-1}function ve(e,n,t){var r=l.exec(n.slice(t,t+6));return r?(e.L=Math.floor(r[0]/1e3),t+r[0].length):-1}function ye(e,n,t){var r=E.exec(n.slice(t,t+1));return r?t+r[0].length:-1}function Me(e,n,t){var r=l.exec(n.slice(t));return r?(e.Q=+r[0],t+r[0].length):-1}function be(e,n,t){var r=l.exec(n.slice(t));return r?(e.s=+r[0],t+r[0].length):-1}function De(e,n){return p(e.getDate(),n,2)}function Fe(e,n){return p(e.getHours(),n,2)}function we(e,n){return p(e.getHours()%12||12,n,2)}function Te(e,n){return p(1+Q.count(i(e),e),n,3)}function xe(e,n){return p(e.getMilliseconds(),n,3)}function Ce(e,n){return xe(e,n)+"000"}function Ye(e,n){return p(e.getMonth()+1,n,2)}function Ue(e,n){return p(e.getMinutes(),n,2)}function Se(e,n){return p(e.getSeconds(),n,2)}function _e(e){var n=e.getDay();return n===0?7:n}function He(e,n){return p(S.count(i(e)-1,e),n,2)}function Z(e){var n=e.getDay();return n>=4||n===0?r(e):r.ceil(e)}function je(e,n){e=Z(e);return p(r.count(i(e),e)+(i(e).getDay()===4),n,2)}function Ae(e){return e.getDay()}function ke(e,n){return p(W.count(i(e)-1,e),n,2)}function $e(e,n){return p(e.getFullYear()%100,n,2)}function ze(e,n){e=Z(e);return p(e.getFullYear()%100,n,2)}function Ne(e,n){return p(e.getFullYear()%1e4,n,4)}function Oe(e,n){var t=e.getDay();e=t>=4||t===0?r(e):r.ceil(e);return p(e.getFullYear()%1e4,n,4)}function Le(e){var n=e.getTimezoneOffset();return(n>0?"-":(n*=-1,"+"))+p(n/60|0,"0",2)+p(n%60,"0",2)}function Ee(e,n){return p(e.getUTCDate(),n,2)}function Ie(e,n){return p(e.getUTCHours(),n,2)}function Be(e,n){return p(e.getUTCHours()%12||12,n,2)}function Ze(e,n){return p(1+V.count(s(e),e),n,3)}function qe(e,n){return p(e.getUTCMilliseconds(),n,3)}function Qe(e,n){return qe(e,n)+"000"}function We(e,n){return p(e.getUTCMonth()+1,n,2)}function Ve(e,n){return p(e.getUTCMinutes(),n,2)}function Xe(e,n){return p(e.getUTCSeconds(),n,2)}function Pe(e){var n=e.getUTCDay();return n===0?7:n}function Je(e,n){return p(k.count(s(e)-1,e),n,2)}function q(e){var n=e.getUTCDay();return n>=4||n===0?o(e):o.ceil(e)}function Ge(e,n){e=q(e);return p(o.count(s(e),e)+(s(e).getUTCDay()===4),n,2)}function Re(e){return e.getUTCDay()}function Ke(e,n){return p(X.count(s(e)-1,e),n,2)}function en(e,n){return p(e.getUTCFullYear()%100,n,2)}function nn(e,n){e=q(e);return p(e.getUTCFullYear()%100,n,2)}function tn(e,n){return p(e.getUTCFullYear()%1e4,n,4)}function rn(e,n){var t=e.getUTCDay();e=t>=4||t===0?o(e):o.ceil(e);return p(e.getUTCFullYear()%1e4,n,4)}function un(){return"+0000"}function an(){return"%"}function on(e){return+e}function fn(e){return Math.floor(+e/1e3)}var d;var cn;var sn;ln({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function ln(e){d=L(e);d.format;d.parse;cn=d.utcFormat;sn=d.utcParse;return d}function g(e){throw new TypeError("Expected a value of type string but got a value of type "+typeof e)}function m(n){return function(e){if(typeof e!=="string")g(e);e=e.trim();return e?n(e):null}}var pn=new Date(1972,3,27,19,45,5);var h={"%b %d":[{regex:/^june\s(30|[12][0-9]|0?[1-9])$/i,toDate:function(e){return new Date(null,5,e.split(/\s/)[1])}},{regex:/^july\s(3[01]|[12][0-9]|0?[1-9])$/i,toDate:function(e){return new Date(null,6,e.split(/\s/)[1])}},{regex:/^sept\s(30|[12][0-9]|0?[1-9])$/i,toDate:function(e){return new Date(null,8,e.split(/\s/)[1])}}],"%d %b":[{regex:/^(0?[1-9]|[1-9][0-9])\sjune$/i,toDate:function(e){return new Date(null,5,e.split(/\s/)[0])}},{regex:/^(0?[1-9]|[1-9][0-9])\sjuly$/i,toDate:function(e){return new Date(null,6,e.split(/\s/)[0])}},{regex:/^(0?[1-9]|[1-9][0-9])\ssept$/i,toDate:function(e){return new Date(null,8,e.split(/\s/)[0])}}]};function v(e){return function(t){var r=null;e.forEach(function(e){var n=t.match(e.regex);if(n)r=e.toDate(t)});return r}}function y(n,t){var r=sn(n);var u=cn(n);var e;if(typeof t==="function"){e=m(function(e){return t(e,r(e)!==null)})}else{e=m(function(e){return r(e)!==null})}return Object.freeze({test:e,parse:m(function(e){return r(e)||(h[n]?v(h[n])(e):null)}),format:function(e){return u(e)},type:"datetime",description:n,id:"datetime$"+n,example:u(pn)})}var M=Object.freeze([y("%Y-%m-%dT%H:%M:%S.%LZ"),y("%Y-%m-%d %H:%M:%S"),y("%Y-%m-%dT%H:%M:%S"),y("%Y-%m-%dT%H:%M:%SZ"),y("%d/%m/%Y",function(e,n){if(!n)return false;var t=e.split("/").map(parseFloat);return t[0]>0&&t[0]<=31&&t[1]>0&&t[1]<=12&&t[2]>=1e3}),y("%d/%m/%Y %H:%M",function(e,n){if(!n)return false;var t=e.split(/[/ :]/).map(parseFloat);return t[0]>0&&t[0]<=31&&t[1]>0&&t[1]<=12&&t[2]>=1e3&&t[3]>=0&&t[3]<24&&t[4]>=0&&t[4]<60}),y("%d/%m/%y",function(e,n){if(!n)return false;var t=e.split("/").map(parseFloat);return t[0]>0&&t[0]<=31&&t[1]>0&&t[1]<=12&&!isNaN(t[2])}),y("%m/%d/%Y",function(e,n){if(!n)return false;var t=e.split("/").map(parseFloat);return t[0]>0&&t[0]<=12&&t[1]>0&&t[1]<=31&&t[2]>=1e3}),y("%m/%d/%Y %H:%M",function(e,n){if(!n)return false;var t=e.split(/[/ :]/).map(parseFloat);return t[0]>0&&t[0]<=12&&t[1]>0&&t[1]<=31&&t[2]>=1e3&&t[3]>=0&&t[3]<24&&t[4]>=0&&t[4]<60}),y("%m/%d/%y",function(e,n){if(!n)return false;var t=e.split("/").map(parseFloat);return t[0]>0&&t[0]<=12&&t[1]>0&&t[1]<=31&&!isNaN(t[2])}),y("%Y/%m/%d",function(e,n){if(!n)return false;var t=e.split("/").map(parseFloat);return t[0]>=1e3&&t[1]>0&&t[1]<=12&&t[2]>0&&t[2]<=31}),y("%d-%m-%Y",function(e,n){if(!n)return false;var t=e.split("-").map(parseFloat);return t[0]>0&&t[0]<=31&&t[1]>0&&t[1]<=12&&t[2]>=1e3}),y("%d-%m-%y",function(e,n){if(!n)return false;var t=e.split("-").map(parseFloat);return t[0]>0&&t[0]<=31&&t[1]>0&&t[1]<=12&&!isNaN(t[2])}),y("%d.%m.%Y",function(e,n){if(!n)return false;var t=e.split(".").map(parseFloat);return t[0]>0&&t[0]<=31&&t[1]>0&&t[1]<=12&&t[2]>=1e3}),y("%m.%d.%y",function(e,n){if(!n)return false;var t=e.split(".").map(parseFloat);return t[0]>0&&t[0]<=12&&t[1]>0&&t[1]<=31&&!isNaN(t[2])}),y("%m-%d-%Y",function(e,n){if(!n)return false;var t=e.split("-").map(parseFloat);return t[0]>0&&t[0]<=12&&t[1]>0&&t[1]<=31&&t[2]>=1e3}),y("%m-%d-%y",function(e,n){if(!n)return false;var t=e.split("-").map(parseFloat);return t[0]>0&&t[0]<=12&&t[1]>0&&t[1]<=31&&!isNaN(t[2])}),y("%Y-%m-%d",function(e,n){if(!n)return false;var t=e.split("-").map(parseFloat);return t[0]>=1e3&&t[1]>0&&t[1]<=12&&t[2]>0&&t[2]<=31}),y("%Y-%m",function(e,n){if(!n)return false;var t=e.split("-").map(parseFloat);return t[0]>=1e3&&t[1]>0&&t[1]<=12}),y("%Y%m",function(e,n){if(!n)return false;var t=parseFloat(e.slice(0,4));var r=parseFloat(e.slice(4));return t>1e3&&r>0&&r<=12}),y("%d %b %Y",function(e,n){if(!n)return false;var t=e.split(" ").map(parseFloat);return t[0]>0&&t[0]<=31&&t[2]>=1e3}),y("%d %B %Y",function(e,n){if(!n)return false;var t=e.split(" ").map(parseFloat);return t[0]>0&&t[0]<=31&&t[2]>=1e3}),y("%d %b %y"),y("%-d %b ’%y"),y("%d %B %y"),y("%d-%b-%Y",function(e,n){if(!n)return false;var t=e.split("-").map(parseFloat);return t[0]>0&&t[0]<=31&&t[2]>=1e3}),y("%d-%B-%Y",function(e,n){if(!n)return false;var t=e.split("-").map(parseFloat);return t[0]>0&&t[0]<=31&&t[2]>=1e3}),y("%d-%b-%y"),y("%d-%B-%y"),y("%m/%Y",function(e,n){if(!n)return false;var t=e.split("/").map(parseFloat);return t[0]>0&&t[0]<=12&&t[1]>=1e3}),y("%m/%y"),y("%b %Y",function(e,n){if(!n)return false;var t=e.split(" ").map(parseFloat);return t[1]>=1e3}),y("%B %Y",function(e,n){if(!n)return false;var t=e.split(" ").map(parseFloat);return t[1]>=1e3}),y("%b-%y"),y("%b %y"),y("%B %y"),y("%b '%y"),y("%b ’%y"),y("%B %-d %Y"),y("%d %b",function(e,n){if(n)return true;return!!v(h["%d %b"])(e)}),y("%d %B"),y("%b %d",function(e,n){if(n)return true;return!!v(h["%b %d"])(e)}),y("%B %d"),y("%d-%m",function(e,n){if(!n)return false;var t=e.split("-").map(parseFloat);return t[0]>0&&t[0]<=31&&t[1]>0&&t[1]<=12}),y("%m-%d"),y("%d/%m"),y("%m/%d"),y("%b %d %Y"),y("%b %d %Y, %-I.%M%p"),y("%Y",function(e,n){if(!n)return false;var t=parseFloat(e);return t>1499&&t<2200}),y("%B"),y("%b"),y("%X"),y("%I:%M %p"),y("%-I.%M%p"),y("%H:%M",function(e,n){if(!n)return false;var t=e.split(":").map(parseFloat);return t[0]>=0&&t[0]<24}),y("%H:%M:%S"),y("%M:%S"),y("%-I%p"),y("Q%q %Y",function(e,n){if(!n)return false;return e.replace(/\s/g,"").length===6}),y("%Y Q%q",function(e,n){if(!n)return false;return e.replace(/\s/g,"").length===6}),y("%YM%m",function(e,n){if(!n)return false;var t=e.split("M").map(parseFloat);return t[0]>=1e3&&t[1]>0&&t[1]<=12}),y("%YQ%q",function(e,n){if(!n)return false;var t=e.split("Q").map(parseFloat);return t[0]>=1e3&&t[1]>0&&t[1]<=4}),y("%YÁ%q",function(e,n){if(!n)return false;var t=e.split("Á").map(parseFloat);return t[0]>=1e3&&t[1]>0&&t[1]<=4})]);function dn(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function b(e,n){if((t=(e=n?e.toExponential(n-1):e.toExponential()).indexOf("e"))<0)return null;var t,r=e.slice(0,t);return[r.length>1?r[0]+r.slice(2):r,+e.slice(t+1)]}function gn(e){return e=b(Math.abs(e)),e?e[1]:NaN}function mn(o,f){return function(e,n){var t=e.length,r=[],u=0,i=o[0],a=0;while(t>0&&i>0){if(a+i+1>n)i=Math.max(1,n-a);r.push(e.substring(t-=i,t+i));if((a+=i+1)>n)break;i=o[u=(u+1)%o.length]}return r.reverse().join(f)}}function hn(n){return function(e){return e.replace(/[0-9]/g,function(e){return n[+e]})}}var vn=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Y(e){if(!(n=vn.exec(e)))throw new Error("invalid format: "+e);var n;return new D({fill:n[1],align:n[2],sign:n[3],symbol:n[4],zero:n[5],width:n[6],comma:n[7],precision:n[8]&&n[8].slice(1),trim:n[9],type:n[10]})}Y.prototype=D.prototype;function D(e){this.fill=e.fill===undefined?" ":e.fill+"";this.align=e.align===undefined?">":e.align+"";this.sign=e.sign===undefined?"-":e.sign+"";this.symbol=e.symbol===undefined?"":e.symbol+"";this.zero=!!e.zero;this.width=e.width===undefined?undefined:+e.width;this.comma=!!e.comma;this.precision=e.precision===undefined?undefined:+e.precision;this.trim=!!e.trim;this.type=e.type===undefined?"":e.type+""}D.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===undefined?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===undefined?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function yn(e){e:for(var n=e.length,t=1,r=-1,u;t<n;++t){switch(e[t]){case".":r=u=t;break;case"0":if(r===0)r=t;u=t;break;default:if(!+e[t])break e;if(r>0)r=0;break}}return r>0?e.slice(0,r)+e.slice(u+1):e}var Mn;function bn(e,n){var t=b(e,n);if(!t)return e+"";var r=t[0],u=t[1],i=u-(Mn=Math.max(-8,Math.min(8,Math.floor(u/3)))*3)+1,a=r.length;return i===a?r:i>a?r+new Array(i-a+1).join("0"):i>0?r.slice(0,i)+"."+r.slice(i):"0."+new Array(1-i).join("0")+b(e,Math.max(0,n+i-1))[0]}function Dn(e,n){var t=b(e,n);if(!t)return e+"";var r=t[0],u=t[1];return u<0?"0."+new Array(-u).join("0")+r:r.length>u+1?r.slice(0,u+1)+"."+r.slice(u+1):r+new Array(u-r.length+2).join("0")}var Fn={"%":function(e,n){return(e*100).toFixed(n)},b:function(e){return Math.round(e).toString(2)},c:function(e){return e+""},d:dn,e:function(e,n){return e.toExponential(n)},f:function(e,n){return e.toFixed(n)},g:function(e,n){return e.toPrecision(n)},o:function(e){return Math.round(e).toString(8)},p:function(e,n){return Dn(e*100,n)},r:Dn,s:bn,X:function(e){return Math.round(e).toString(16).toUpperCase()},x:function(e){return Math.round(e).toString(16)}};function wn(e){return e}var Tn=Array.prototype.map,xn=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Cn(e){var F=e.grouping===undefined||e.thousands===undefined?wn:mn(Tn.call(e.grouping,Number),e.thousands+""),r=e.currency===undefined?"":e.currency[0]+"",u=e.currency===undefined?"":e.currency[1]+"",w=e.decimal===undefined?".":e.decimal+"",T=e.numerals===undefined?wn:hn(Tn.call(e.numerals,String)),i=e.percent===undefined?"%":e.percent+"",x=e.minus===undefined?"-":e.minus+"",C=e.nan===undefined?"NaN":e.nan+"";function a(e){e=Y(e);var c=e.fill,s=e.align,l=e.sign,n=e.symbol,p=e.zero,d=e.width,g=e.comma,m=e.precision,h=e.trim,v=e.type;if(v==="n")g=true,v="g";else if(!Fn[v])m===undefined&&(m=12),h=true,v="g";if(p||c==="0"&&s==="=")p=true,c="0",s="=";var y=n==="$"?r:n==="#"&&/[boxX]/.test(v)?"0"+v.toLowerCase():"",M=n==="$"?u:/[%p]/.test(v)?i:"";var b=Fn[v],D=/[defgprs%]/.test(v);m=m===undefined?6:/[gprs]/.test(v)?Math.max(1,Math.min(21,m)):Math.max(0,Math.min(20,m));function t(e){var n=y,t=M,r,u,i;if(v==="c"){t=b(e)+t;e=""}else{e=+e;var a=e<0||1/e<0;e=isNaN(e)?C:b(Math.abs(e),m);if(h)e=yn(e);if(a&&+e===0&&l!=="+")a=false;n=(a?l==="("?l:x:l==="-"||l==="("?"":l)+n;t=(v==="s"?xn[8+Mn/3]:"")+t+(a&&l==="("?")":"");if(D){r=-1,u=e.length;while(++r<u){if(i=e.charCodeAt(r),48>i||i>57){t=(i===46?w+e.slice(r+1):e.slice(r))+t;e=e.slice(0,r);break}}}}if(g&&!p)e=F(e,Infinity);var o=n.length+e.length+t.length,f=o<d?new Array(d-o+1).join(c):"";if(g&&p)e=F(f+e,f.length?d-t.length:Infinity),f="";switch(s){case"<":e=n+e+t+f;break;case"=":e=n+f+e+t;break;case"^":e=f.slice(0,o=f.length>>1)+n+e+t+f.slice(o);break;default:e=f+n+e+t;break}return T(e)}t.toString=function(){return e+""};return t}function n(e,n){var t=a((e=Y(e),e.type="f",e)),r=Math.max(-8,Math.min(8,Math.floor(gn(n)/3)))*3,u=Math.pow(10,-r),i=xn[8+r/3];return function(e){return t(u*e)+i}}return{format:a,formatPrefix:n}}function Yn(e){var n=e.decimal_mark;var t=e.thousand_separator;var r=Cn({decimal:n,thousands:t,grouping:[3],currency:["",""]});var u,i;return function(e,n){if(e===null)return"";if(!n)n=",.2f";if(n!==i){i=n;u=r.format(i)}return u(e)}}var Un={test:m(function(e){return/^(\+|-)?\d{1,3}(,\d{3})*(\.\d+)?((e|E)(\+|-)?\d+)?$/.test(e.trim())}),parse:m(function(e){return parseFloat(e.replace(/,/g,""))}),description:"Comma thousand separator, point decimal mark",thousand_separator:",",decimal_mark:".",id:"number$comma_point",example:"12,235.56"};var Sn={test:m(function(e){return/^(\+|-)?\d{1,3}(\s\d{3})*(\.\d+)?((e|E)(\+|-)?\d+)?$/.test(e.trim())}),parse:m(function(e){return parseFloat(e.replace(/\s/g,""))}),description:"Space thousand separator, point decimal mark",thousand_separator:" ",decimal_mark:".",id:"number$space_point",example:"12 235.56"};var _n={test:m(function(e){return/^(\+|-)?\d+(\.\d+)?((e|E)(\+|-)?\d+)?$/.test(e.trim())}),parse:m(function(e){return parseFloat(e)}),description:"No thousand separator, point decimal mark",thousand_separator:"",decimal_mark:".",id:"number$none_point",example:"12235.56"};var Hn={test:m(function(e){return/^(\+|-)?\d{1,3}(\.\d{3})*(,\d+)?((e|E)(\+|-)?\d+)?$/.test(e.trim())}),parse:m(function(e){return parseFloat(e.replace(/\./g,"").replace(/,/,"."))}),description:"Point thousand separator, comma decimal mark",thousand_separator:".",decimal_mark:",",id:"number$point_comma",example:"12.235,56"};var jn={test:m(function(e){return/^(\+|-)?\d{1,3}(\s\d{3})*(,\d+)?((e|E)(\+|-)?\d+)?$/.test(e.trim())}),parse:m(function(e){return parseFloat(e.replace(/\s/g,"").replace(/,/,"."))}),description:"Space thousand separator, comma decimal mark",thousand_separator:" ",decimal_mark:",",id:"number$space_comma",example:"12 235,56"};var An={test:m(function(e){return/^(\+|-)?\d+(,\d+)?((e|E)(\+|-)?\d+)?$/.test(e.trim())}),parse:m(function(e){return parseFloat(e.replace(/,/,"."))}),description:"No thousand separator, comma decimal mark",thousand_separator:"",decimal_mark:",",id:"number$none_comma",example:"12235,56"};var F=Object.freeze([Un,Sn,Hn,jn,_n,An]);F.forEach(function(e){e.type="number";e.format=Yn(e);Object.freeze(e)});var w=Object.freeze({test:function(e){return typeof e==="string"?true:g(e)},parse:function(e){return typeof e==="string"?e:g(e)},format:function(e){if(typeof e==="string")return e},type:"string",description:"Arbitrary string",id:"string$arbitrary_string"});var kn=Object.freeze({datetime:M,number:F});var $n=Object.freeze(["datetime","number","string"]);var zn=Object.freeze({n_max:250,n_failing_values:0,failure_fraction:5/100,sort:true});var Nn=Object.freeze(Object.keys(zn));function On(e){return e.replace(/_(\w)/g,function(e,n){return n.toUpperCase()})}function Ln(e,n){return e.index-n.index}function En(e,n){return n.n_success-e.n_success||Ln(e,n)}function T(e){return(""+e).trim()}function In(t){if(t===undefined)return function(e){return T(e)};if(typeof t==="function")return function(e,n){return T(t(e,n))};return function(e){return T(e[""+t])}}function x(e){if(!e)e=$n;else if(!Array.isArray(e))e=[e];var u=e.reduce(function(e,n){var t=kn[n];if(t)Array.prototype.push.apply(e,t);return e},[]);var i=e.indexOf("string")!==-1;var a=Nn.reduce(function(e,n){e[n]=zn[n];return e},{});var t=function(e,n){n=In(n);var c=e.map(n).filter(Boolean);if(!c.length)return i?[w]:[];var s=Math.min(a.n_max,c.length);var l=Math.floor(s*a.failure_fraction);var p=a.n_failing_values;var t=a.sort?En:Ln;var r=u.slice().reduce(function(e,n,t){var r=a=0;var u=[];var i=false;for(var a=0;a<s;a++){var o=c[a];var f=n.test(o);if(f)continue;if(++r>l)i=true;else if(u.indexOf(o)===-1){u.push(o);if(u.length>p)i=true}if(i)break}if(!i)e.push({interp:n,n_success:s-r,index:t});return e},[]).sort(t).map(function(e){return e.interp});if(i)r.push(w);return r};Nn.forEach(function(n){t[On(n)]=function(e){if(e===undefined)return a[n];a[n]=e;return t}});return t}x.DATETIME_IDS=Object.freeze(M.map(function(e){return e.id}));x.NUMBER_IDS=Object.freeze(F.map(function(e){return e.id}));x.STRING_IDS=Object.freeze([w.id]);x.getInterpretation=function(){var e=M.concat(F,w);var n=e.reduce(function(e,n){e[n.id]=n;return e},{});return function(e){return n[e]}}();x._createAccessorFunction=In;var Bn=kn;e.createInterpreter=x;e.recognised_formats=Bn});
{
"name": "@flourish/interpreter",
"type": "module",
"version": "9.0.0",
"version": "9.1.0",
"private": false,

@@ -27,9 +27,16 @@ "description": "Does a best guess at the type of data supplied",

"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-node-resolve": "^15.2.3",
"chai": "^4.2.0",
"eslint": "^8.35.0",
"mocha": "^10.2.0",
"only-allow": "^1.2.1",
"rollup": "^4.6.1",
"@rollup/plugin-node-resolve": "^15.2.3",
"uglify-js": "^3.6.4"
"uglify-js": "^3.6.4",
"@flourish/mocha-env": "^1.0.0"
},
"mocha": {
"spec": "**/*.test.{js,cjs,mjs,ts}",
"recursive": true,
"require": "@flourish/mocha-env"
},
"scripts": {

@@ -39,4 +46,5 @@ "build": "rollup -c",

"minify": "uglifyjs -m -o interpreter.min.js interpreter.js",
"test": "npm run build && mocha"
"test": "npm run mocha",
"mocha": "mocha"
}
}

@@ -0,1 +1,4 @@

# 9.1.0
* Add "%e %B %Y", "%YM%m", "%YQ%q" and "%YÁ%q" datetime formats
# 9.0.0

@@ -2,0 +5,0 @@ * Switch to preferring ESM by default on recent versions of Node.js by adding an `exports` field to `package.json`.

@@ -10,3 +10,7 @@ import { datetime_interpretations } from "./types/datetime.js";

var DEFAULT_INTERPRETATIONS_ARRAY = Object.freeze([ "datetime", "number", "string" ]);
var DEFAULT_INTERPRETATIONS_ARRAY = Object.freeze([
"datetime",
"number",
"string",
]);

@@ -17,3 +21,3 @@ var DEFAULT_OPTIONS = Object.freeze({

failure_fraction: 5 / 100,
sort: true
sort: true,
});

@@ -24,3 +28,3 @@

function snakeToCamel(snake_string) {
return snake_string.replace(/_(\w)/g, function(match, capture) {
return snake_string.replace(/_(\w)/g, function (match, capture) {
return capture.toUpperCase();

@@ -30,4 +34,8 @@ });

function noSort(a, b) { return a.index - b.index; }
function sortBySuccess(a, b) { return b.n_success - a.n_success || noSort(a, b); }
function noSort(a, b) {
return a.index - b.index;
}
function sortBySuccess(a, b) {
return b.n_success - a.n_success || noSort(a, b);
}

@@ -39,12 +47,25 @@ function trim(value) {

function createAccessorFunction(accessor) {
if (accessor === undefined) return function(value) { return trim(value); };
if (typeof accessor === "function") return function(value, index) { return trim(accessor(value, index)); };
return function(value) { return trim(value["" + accessor]); };
if (accessor === undefined)
return function (value) {
return trim(value);
};
if (typeof accessor === "function")
return function (value, index) {
return trim(accessor(value, index));
};
return function (value) {
return trim(value["" + accessor]);
};
}
export function createInterpreter(interpretations_array) {
if (!interpretations_array) interpretations_array = DEFAULT_INTERPRETATIONS_ARRAY;
else if (!Array.isArray(interpretations_array)) interpretations_array = [interpretations_array];
if (!interpretations_array)
interpretations_array = DEFAULT_INTERPRETATIONS_ARRAY;
else if (!Array.isArray(interpretations_array))
interpretations_array = [interpretations_array];
var interpretations = interpretations_array.reduce(function(arr, interp_string) {
var interpretations = interpretations_array.reduce(function (
arr,
interp_string,
) {
var interps = INTERPRETATION_OPTIONS[interp_string];

@@ -57,3 +78,3 @@ if (interps) Array.prototype.push.apply(arr, interps);

var options = OPTION_KEYS.reduce(function(obj, key) {
var options = OPTION_KEYS.reduce(function (obj, key) {
obj[key] = DEFAULT_OPTIONS[key];

@@ -63,5 +84,5 @@ return obj;

var interpreter = function(input_array, accessor) {
var interpreter = function (input_array, accessor) {
accessor = createAccessorFunction(accessor);
var data = input_array.map(accessor).filter(function(x) { return x; });
var data = input_array.map(accessor).filter(Boolean);
if (!data.length) return include_string ? [string_interpretation] : [];

@@ -73,28 +94,31 @@ var n = Math.min(options.n_max, data.length);

var valid_interpreters = interpretations.slice()
.reduce(function(keep, interp, index) {
var n_fail = i = 0;
var failing_values = [];
var complete_failure = false;
var valid_interpreters = interpretations
.slice()
.reduce(function (keep, interp, index) {
var n_fail = (i = 0);
var failing_values = [];
var complete_failure = false;
for (var i = 0; i < n; i++) {
var val = data[i];
var is_valid = interp.test(val);
if (is_valid) continue;
if (++n_fail > n_max_failure) complete_failure = true;
else if (failing_values.indexOf(val) === -1) {
failing_values.push(val);
if (failing_values.length > n_failing_values) complete_failure = true;
for (var i = 0; i < n; i++) {
var val = data[i];
var is_valid = interp.test(val);
if (is_valid) continue;
if (++n_fail > n_max_failure) complete_failure = true;
else if (failing_values.indexOf(val) === -1) {
failing_values.push(val);
if (failing_values.length > n_failing_values)
complete_failure = true;
}
if (complete_failure) break;
}
if (complete_failure) break;
}
if (!complete_failure) keep.push({ interp: interp, n_success: n - n_fail, index: index });
if (!complete_failure)
keep.push({ interp: interp, n_success: n - n_fail, index: index });
return keep;
}, [])
.sort(sortMethod)
.map(function(valid) {
return valid.interp;
});
return keep;
}, [])
.sort(sortMethod)
.map(function (valid) {
return valid.interp;
});

@@ -106,4 +130,4 @@ if (include_string) valid_interpreters.push(string_interpretation);

OPTION_KEYS.forEach(function(option) {
interpreter[snakeToCamel(option)] = function(value) {
OPTION_KEYS.forEach(function (option) {
interpreter[snakeToCamel(option)] = function (value) {
if (value === undefined) return options[option];

@@ -118,10 +142,26 @@ options[option] = value;

createInterpreter.DATETIME_IDS = Object.freeze(datetime_interpretations.map(function(d) { return d.id; }));
createInterpreter.NUMBER_IDS = Object.freeze(number_interpretations.map(function(d) { return d.id; }));
createInterpreter.DATETIME_IDS = Object.freeze(
datetime_interpretations.map(function (d) {
return d.id;
}),
);
createInterpreter.NUMBER_IDS = Object.freeze(
number_interpretations.map(function (d) {
return d.id;
}),
);
createInterpreter.STRING_IDS = Object.freeze([string_interpretation.id]);
createInterpreter.getInterpretation = (function() {
var interpretations = datetime_interpretations.concat(number_interpretations, string_interpretation);
var lookup = interpretations.reduce(function(l, d) { l[d.id] = d; return l; }, {});
return function(id) { return lookup[id]; };
createInterpreter.getInterpretation = (function () {
var interpretations = datetime_interpretations.concat(
number_interpretations,
string_interpretation,
);
var lookup = interpretations.reduce(function (l, d) {
l[d.id] = d;
return l;
}, {});
return function (id) {
return lookup[id];
};
})();

@@ -132,2 +172,1 @@

export var recognised_formats = INTERPRETATION_OPTIONS;
function notAStringError(not_a_str) {
throw new TypeError("Expected a value of type string but got a value of type " + (typeof not_a_str));
throw new TypeError(
"Expected a value of type string but got a value of type " +
typeof not_a_str,
);
}
function shield(func) {
return function(str) {
return function (str) {
if (typeof str !== "string") notAStringError(str);

@@ -8,0 +11,0 @@ str = str.trim();

@@ -12,11 +12,17 @@ import { utcParse, utcFormat } from "d3-time-format";

regex: /^june\s(30|[12][0-9]|0?[1-9])$/i, // matches dates from June 0-30
toDate: function(str) { return new Date(null, 5, str.split(/\s/)[1]); },
toDate: function (str) {
return new Date(null, 5, str.split(/\s/)[1]);
},
},
{
regex: /^july\s(3[01]|[12][0-9]|0?[1-9])$/i, // matches dates from July 0-31
toDate: function(str) { return new Date(null, 6, str.split(/\s/)[1]); },
toDate: function (str) {
return new Date(null, 6, str.split(/\s/)[1]);
},
},
{
regex: /^sept\s(30|[12][0-9]|0?[1-9])$/i, // matches dates from September 0-30 using the 4-letter 'Sept' abbreviation
toDate: function(str) { return new Date(null, 8, str.split(/\s/)[1]); },
toDate: function (str) {
return new Date(null, 8, str.split(/\s/)[1]);
},
},

@@ -29,11 +35,17 @@ ],

regex: /^(0?[1-9]|[1-9][0-9])\sjune$/i, // matches dates from 0-99 June
toDate: function(str) { return new Date(null, 5, str.split(/\s/)[0]); },
toDate: function (str) {
return new Date(null, 5, str.split(/\s/)[0]);
},
},
{
regex: /^(0?[1-9]|[1-9][0-9])\sjuly$/i, // matches dates from 0-99 July
toDate: function(str) { return new Date(null, 6, str.split(/\s/)[0]); },
toDate: function (str) {
return new Date(null, 6, str.split(/\s/)[0]);
},
},
{
regex: /^(0?[1-9]|[1-9][0-9])\ssept$/i, // matches dates from 0-99 September using the 4-letter 'Sept' abbreviation
toDate: function(str) { return new Date(null, 8, str.split(/\s/)[0]); },
toDate: function (str) {
return new Date(null, 8, str.split(/\s/)[0]);
},
},

@@ -46,5 +58,5 @@ ],

function customDatetimeParser(strftime_formats) {
return function(str) {
return function (str) {
var parsed_datetime = null;
strftime_formats.forEach(function(strftime_format) {
strftime_formats.forEach(function (strftime_format) {
var valid_datetime = str.match(strftime_format.regex);

@@ -62,20 +74,28 @@ if (valid_datetime) parsed_datetime = strftime_format.toDate(str);

if (typeof secondaryTest === "function") {
test = shield(function(str) {
return (secondaryTest(str, parser(str) !== null));
test = shield(function (str) {
return secondaryTest(str, parser(str) !== null);
});
} else {
test = shield(function (str) {
return parser(str) !== null;
});
}
else {
test = shield(function(str) { return parser(str) !== null; });
}
return Object.freeze({
test: test,
parse: shield(function(str) {
return parser(str) || (CUSTOM_FORMAT_REGEXES[format_string] ? customDatetimeParser(CUSTOM_FORMAT_REGEXES[format_string])(str) : null);
parse: shield(function (str) {
return (
parser(str) ||
(CUSTOM_FORMAT_REGEXES[format_string]
? customDatetimeParser(CUSTOM_FORMAT_REGEXES[format_string])(str)
: null)
);
}),
format: function(dt) { return formatter(dt); },
format: function (dt) {
return formatter(dt);
},
type: "datetime",
description: format_string,
id: "datetime$" + format_string,
example: formatter(EXAMPLE_DATETIME)
example: formatter(EXAMPLE_DATETIME),
});

@@ -90,86 +110,150 @@ }

createDatetimeInterpretation("%d/%m/%Y", function(str, passed_primary_test) { // 27/04/1972
createDatetimeInterpretation("%d/%m/%Y", function (str, passed_primary_test) {
// 27/04/1972
if (!passed_primary_test) return false;
var arr = str.split("/").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 31) && (arr[1] > 0 && arr[1] <= 12) && (arr[2] >= 1000);
return (
arr[0] > 0 && arr[0] <= 31 && arr[1] > 0 && arr[1] <= 12 && arr[2] >= 1000
);
}),
createDatetimeInterpretation("%d/%m/%Y %H:%M", function(str, passed_primary_test) { // 27/04/1972 19:45
createDatetimeInterpretation(
"%d/%m/%Y %H:%M",
function (str, passed_primary_test) {
// 27/04/1972 19:45
if (!passed_primary_test) return false;
var arr = str.split(/[/ :]/).map(parseFloat);
return (
arr[0] > 0 &&
arr[0] <= 31 &&
arr[1] > 0 &&
arr[1] <= 12 &&
arr[2] >= 1000 &&
arr[3] >= 0 &&
arr[3] < 24 &&
arr[4] >= 0 &&
arr[4] < 60
);
},
),
createDatetimeInterpretation("%d/%m/%y", function (str, passed_primary_test) {
// 27/04/72
if (!passed_primary_test) return false;
var arr = str.split(/[/ :]/).map(parseFloat);
return (arr[0] > 0 && arr[0] <= 31) && (arr[1] > 0 && arr[1] <= 12) && (arr[2] >= 1000) &&
(arr[3] >= 0 && arr[3] < 24) && (arr[4] >= 0 && arr[4] < 60);
}),
createDatetimeInterpretation("%d/%m/%y", function(str, passed_primary_test) { // 27/04/72
if (!passed_primary_test) return false;
var arr = str.split("/").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 31) && (arr[1] > 0 && arr[1] <= 12) && (!isNaN(arr[2]));
return (
arr[0] > 0 && arr[0] <= 31 && arr[1] > 0 && arr[1] <= 12 && !isNaN(arr[2])
);
}),
createDatetimeInterpretation("%m/%d/%Y", function(str, passed_primary_test) { // 04/27/1972
createDatetimeInterpretation("%m/%d/%Y", function (str, passed_primary_test) {
// 04/27/1972
if (!passed_primary_test) return false;
var arr = str.split("/").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 12) && (arr[1] > 0 && arr[1] <= 31) && (arr[2] >= 1000);
return (
arr[0] > 0 && arr[0] <= 12 && arr[1] > 0 && arr[1] <= 31 && arr[2] >= 1000
);
}),
createDatetimeInterpretation("%m/%d/%Y %H:%M", function(str, passed_primary_test) { // 04/27/1972 19:45
createDatetimeInterpretation(
"%m/%d/%Y %H:%M",
function (str, passed_primary_test) {
// 04/27/1972 19:45
if (!passed_primary_test) return false;
var arr = str.split(/[/ :]/).map(parseFloat);
return (
arr[0] > 0 &&
arr[0] <= 12 &&
arr[1] > 0 &&
arr[1] <= 31 &&
arr[2] >= 1000 &&
arr[3] >= 0 &&
arr[3] < 24 &&
arr[4] >= 0 &&
arr[4] < 60
);
},
),
createDatetimeInterpretation("%m/%d/%y", function (str, passed_primary_test) {
// 04/27/72
if (!passed_primary_test) return false;
var arr = str.split(/[/ :]/).map(parseFloat);
return (arr[0] > 0 && arr[0] <= 12) && (arr[1] > 0 && arr[1] <= 31) && (arr[2] >= 1000) &&
(arr[3] >= 0 && arr[3] < 24) && (arr[4] >= 0 && arr[4] < 60);
}),
createDatetimeInterpretation("%m/%d/%y", function(str, passed_primary_test) { // 04/27/72
if (!passed_primary_test) return false;
var arr = str.split("/").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 12) && (arr[1] > 0 && arr[1] <= 31) && (!isNaN(arr[2]));
return (
arr[0] > 0 && arr[0] <= 12 && arr[1] > 0 && arr[1] <= 31 && !isNaN(arr[2])
);
}),
createDatetimeInterpretation("%Y/%m/%d", function(str, passed_primary_test) { // 1972/04/27
createDatetimeInterpretation("%Y/%m/%d", function (str, passed_primary_test) {
// 1972/04/27
if (!passed_primary_test) return false;
var arr = str.split("/").map(parseFloat);
return (arr[0] >= 1000) && (arr[1] > 0 && arr[1] <= 12) && (arr[2] > 0 && arr[2] <= 31);
return (
arr[0] >= 1000 && arr[1] > 0 && arr[1] <= 12 && arr[2] > 0 && arr[2] <= 31
);
}),
createDatetimeInterpretation("%d-%m-%Y", function(str, passed_primary_test) { // 27-04-1972
createDatetimeInterpretation("%d-%m-%Y", function (str, passed_primary_test) {
// 27-04-1972
if (!passed_primary_test) return false;
var arr = str.split("-").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 31) && (arr[1] > 0 && arr[1] <= 12) && (arr[2] >= 1000);
return (
arr[0] > 0 && arr[0] <= 31 && arr[1] > 0 && arr[1] <= 12 && arr[2] >= 1000
);
}),
createDatetimeInterpretation("%d-%m-%y", function(str, passed_primary_test) { // 27-04-72
createDatetimeInterpretation("%d-%m-%y", function (str, passed_primary_test) {
// 27-04-72
if (!passed_primary_test) return false;
var arr = str.split("-").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 31) && (arr[1] > 0 && arr[1] <= 12) && (!isNaN(arr[2]));
return (
arr[0] > 0 && arr[0] <= 31 && arr[1] > 0 && arr[1] <= 12 && !isNaN(arr[2])
);
}),
createDatetimeInterpretation("%d.%m.%Y", function(str, passed_primary_test) { // 27.04.1972
createDatetimeInterpretation("%d.%m.%Y", function (str, passed_primary_test) {
// 27.04.1972
if (!passed_primary_test) return false;
var arr = str.split(".").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 31) && (arr[1] > 0 && arr[1] <= 12) && (arr[2] >= 1000);
return (
arr[0] > 0 && arr[0] <= 31 && arr[1] > 0 && arr[1] <= 12 && arr[2] >= 1000
);
}),
createDatetimeInterpretation("%m.%d.%y", function(str, passed_primary_test) { // 04.27.72
createDatetimeInterpretation("%m.%d.%y", function (str, passed_primary_test) {
// 04.27.72
if (!passed_primary_test) return false;
var arr = str.split(".").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 12) && (arr[1] > 0 && arr[1] <= 31) && (!isNaN(arr[2]));
return (
arr[0] > 0 && arr[0] <= 12 && arr[1] > 0 && arr[1] <= 31 && !isNaN(arr[2])
);
}),
createDatetimeInterpretation("%m-%d-%Y", function(str, passed_primary_test) { // 04-27-1972
createDatetimeInterpretation("%m-%d-%Y", function (str, passed_primary_test) {
// 04-27-1972
if (!passed_primary_test) return false;
var arr = str.split("-").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 12) && (arr[1] > 0 && arr[1] <= 31) && (arr[2] >= 1000);
return (
arr[0] > 0 && arr[0] <= 12 && arr[1] > 0 && arr[1] <= 31 && arr[2] >= 1000
);
}),
createDatetimeInterpretation("%m-%d-%y", function(str, passed_primary_test) { // 04-27-72
createDatetimeInterpretation("%m-%d-%y", function (str, passed_primary_test) {
// 04-27-72
if (!passed_primary_test) return false;
var arr = str.split("-").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 12) && (arr[1] > 0 && arr[1] <= 31) && (!isNaN(arr[2]));
return (
arr[0] > 0 && arr[0] <= 12 && arr[1] > 0 && arr[1] <= 31 && !isNaN(arr[2])
);
}),
createDatetimeInterpretation("%Y-%m-%d", function(str, passed_primary_test) { // 1972-04-27
createDatetimeInterpretation("%Y-%m-%d", function (str, passed_primary_test) {
// 1972-04-27
if (!passed_primary_test) return false;
var arr = str.split("-").map(parseFloat);
return (arr[0] >= 1000) && (arr[1] > 0 && arr[1] <= 12) && (arr[2] > 0 && arr[2] <= 31);
return (
arr[0] >= 1000 && arr[1] > 0 && arr[1] <= 12 && arr[2] > 0 && arr[2] <= 31
);
}),
createDatetimeInterpretation("%Y-%m", function(str, passed_primary_test) { // 1972-04
createDatetimeInterpretation("%Y-%m", function (str, passed_primary_test) {
// 1972-04
if (!passed_primary_test) return false;
var arr = str.split("-").map(parseFloat);
return (arr[0] >= 1000) && (arr[1] > 0 && arr[1] <= 12);
return arr[0] >= 1000 && arr[1] > 0 && arr[1] <= 12;
}),
createDatetimeInterpretation("%Y%m", function(str, passed_primary_test) { // 197204
createDatetimeInterpretation("%Y%m", function (str, passed_primary_test) {
// 197204
if (!passed_primary_test) return false;

@@ -181,11 +265,13 @@ var year = parseFloat(str.slice(0, 4));

createDatetimeInterpretation("%d %b %Y", function(str, passed_primary_test) { // 27 Apr 1972
createDatetimeInterpretation("%d %b %Y", function (str, passed_primary_test) {
// 27 Apr 1972
if (!passed_primary_test) return false;
var arr = str.split(" ").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 31) && (arr[2] >= 1000);
return arr[0] > 0 && arr[0] <= 31 && arr[2] >= 1000;
}),
createDatetimeInterpretation("%d %B %Y", function(str, passed_primary_test) { // 27 April 1972
createDatetimeInterpretation("%d %B %Y", function (str, passed_primary_test) {
// 27 April 1972
if (!passed_primary_test) return false;
var arr = str.split(" ").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 31) && (arr[2] >= 1000);
return arr[0] > 0 && arr[0] <= 31 && arr[2] >= 1000;
}),

@@ -195,11 +281,13 @@ createDatetimeInterpretation("%d %b %y"), // 27 Apr 72

createDatetimeInterpretation("%d %B %y"), // 27 April 72
createDatetimeInterpretation("%d-%b-%Y", function(str, passed_primary_test) { // 27-Apr-1972
createDatetimeInterpretation("%d-%b-%Y", function (str, passed_primary_test) {
// 27-Apr-1972
if (!passed_primary_test) return false;
var arr = str.split("-").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 31) && (arr[2] >= 1000);
return arr[0] > 0 && arr[0] <= 31 && arr[2] >= 1000;
}),
createDatetimeInterpretation("%d-%B-%Y", function(str, passed_primary_test) { // 27-April-1972
createDatetimeInterpretation("%d-%B-%Y", function (str, passed_primary_test) {
// 27-April-1972
if (!passed_primary_test) return false;
var arr = str.split("-").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 31) && (arr[2] >= 1000);
return arr[0] > 0 && arr[0] <= 31 && arr[2] >= 1000;
}),

@@ -209,17 +297,20 @@ createDatetimeInterpretation("%d-%b-%y"), // 27-Apr-72

createDatetimeInterpretation("%m/%Y", function(str, passed_primary_test) { // 04/1972
createDatetimeInterpretation("%m/%Y", function (str, passed_primary_test) {
// 04/1972
if (!passed_primary_test) return false;
var arr = str.split("/").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 12) && (arr[1] >= 1000);
return arr[0] > 0 && arr[0] <= 12 && arr[1] >= 1000;
}),
createDatetimeInterpretation("%m/%y"), // 04/72
createDatetimeInterpretation("%b %Y", function(str, passed_primary_test) { // Apr 1972
createDatetimeInterpretation("%b %Y", function (str, passed_primary_test) {
// Apr 1972
if (!passed_primary_test) return false;
var arr = str.split(" ").map(parseFloat);
return (arr[1] >= 1000);
return arr[1] >= 1000;
}),
createDatetimeInterpretation("%B %Y", function(str, passed_primary_test) { // April 1972
createDatetimeInterpretation("%B %Y", function (str, passed_primary_test) {
// April 1972
if (!passed_primary_test) return false;
var arr = str.split(" ").map(parseFloat);
return (arr[1] >= 1000);
return arr[1] >= 1000;
}),

@@ -233,3 +324,3 @@ createDatetimeInterpretation("%b-%y"), // Apr-72

createDatetimeInterpretation("%d %b", function(str, passed_primary_test) {
createDatetimeInterpretation("%d %b", function (str, passed_primary_test) {
if (passed_primary_test) return true;

@@ -239,3 +330,3 @@ return !!customDatetimeParser(CUSTOM_FORMAT_REGEXES["%d %b"])(str);

createDatetimeInterpretation("%d %B"), // 27 April
createDatetimeInterpretation("%b %d", function(str, passed_primary_test) {
createDatetimeInterpretation("%b %d", function (str, passed_primary_test) {
if (passed_primary_test) return true;

@@ -245,6 +336,7 @@ return !!customDatetimeParser(CUSTOM_FORMAT_REGEXES["%b %d"])(str);

createDatetimeInterpretation("%B %d"), // April 27
createDatetimeInterpretation("%d-%m", function(str, passed_primary_test) { // 27-04
createDatetimeInterpretation("%d-%m", function (str, passed_primary_test) {
// 27-04
if (!passed_primary_test) return false;
var arr = str.split("-").map(parseFloat);
return (arr[0] > 0 && arr[0] <= 31) && (arr[1] > 0 && arr[1] <= 12);
return arr[0] > 0 && arr[0] <= 31 && arr[1] > 0 && arr[1] <= 12;
}),

@@ -257,3 +349,4 @@ createDatetimeInterpretation("%m-%d"), // 04-27

createDatetimeInterpretation("%Y", function(str, passed_primary_test) { // 1972
createDatetimeInterpretation("%Y", function (str, passed_primary_test) {
// 1972
if (!passed_primary_test) return false;

@@ -269,3 +362,4 @@ var val = parseFloat(str);

createDatetimeInterpretation("%-I.%M%p"), // 7.45PM
createDatetimeInterpretation("%H:%M", function(str, passed_primary_test) { // 19:45
createDatetimeInterpretation("%H:%M", function (str, passed_primary_test) {
// 19:45
if (!passed_primary_test) return false;

@@ -279,12 +373,32 @@ var arr = str.split(":").map(parseFloat);

createDatetimeInterpretation("Q%q %Y", function(str, passed_primary_test) { // Q2 1972
createDatetimeInterpretation("Q%q %Y", function (str, passed_primary_test) {
// Q2 1972
if (!passed_primary_test) return false;
return str.replace(/\s/g, "").length === 6;
}),
createDatetimeInterpretation("%Y Q%q", function(str, passed_primary_test) { // 1972 Q2
createDatetimeInterpretation("%Y Q%q", function (str, passed_primary_test) {
// 1972 Q2
if (!passed_primary_test) return false;
return str.replace(/\s/g, "").length === 6;
})
}),
createDatetimeInterpretation("%YM%m", function (str, passed_primary_test) {
// 1972M04
if (!passed_primary_test) return false;
var arr = str.split("M").map(parseFloat);
return arr[0] >= 1000 && arr[1] > 0 && arr[1] <= 12;
}),
createDatetimeInterpretation("%YQ%q", function (str, passed_primary_test) {
// 1972Q2
if (!passed_primary_test) return false;
var arr = str.split("Q").map(parseFloat);
return arr[0] >= 1000 && arr[1] > 0 && arr[1] <= 4;
}),
createDatetimeInterpretation("%YÁ%q", function (str, passed_primary_test) {
// 1972Á2
if (!passed_primary_test) return false;
var arr = str.split("Á").map(parseFloat);
return arr[0] >= 1000 && arr[1] > 0 && arr[1] <= 4;
}),
]);
export { datetime_interpretations };

@@ -7,6 +7,11 @@ import { shield } from "./common.js";

var thousands = interp.thousand_separator;
var locale = formatLocale({decimal: decimal, thousands: thousands, grouping: [3], currency: ["", ""]});
var locale = formatLocale({
decimal: decimal,
thousands: thousands,
grouping: [3],
currency: ["", ""],
});
var format, specifier;
return function(value, spec) {
return function (value, spec) {
if (value === null) return "";

@@ -24,4 +29,10 @@ if (!spec) spec = ",.2f";

var comma_point = {
test: shield(function(str) { return /^(\+|-)?\d{1,3}(,\d{3})*(\.\d+)?((e|E)(\+|-)?\d+)?$/.test(str.trim()); }),
parse: shield(function(str) { return parseFloat(str.replace(/,/g, "")); }),
test: shield(function (str) {
return /^(\+|-)?\d{1,3}(,\d{3})*(\.\d+)?((e|E)(\+|-)?\d+)?$/.test(
str.trim(),
);
}),
parse: shield(function (str) {
return parseFloat(str.replace(/,/g, ""));
}),
description: "Comma thousand separator, point decimal mark",

@@ -31,8 +42,14 @@ thousand_separator: ",",

id: "number$comma_point",
example: "12,235.56"
example: "12,235.56",
};
var space_point = {
test: shield(function(str) { return /^(\+|-)?\d{1,3}(\s\d{3})*(\.\d+)?((e|E)(\+|-)?\d+)?$/.test(str.trim()); }),
parse: shield(function(str) { return parseFloat(str.replace(/\s/g, "")); }),
test: shield(function (str) {
return /^(\+|-)?\d{1,3}(\s\d{3})*(\.\d+)?((e|E)(\+|-)?\d+)?$/.test(
str.trim(),
);
}),
parse: shield(function (str) {
return parseFloat(str.replace(/\s/g, ""));
}),
description: "Space thousand separator, point decimal mark",

@@ -42,8 +59,12 @@ thousand_separator: " ",

id: "number$space_point",
example: "12 235.56"
example: "12 235.56",
};
var none_point = {
test: shield(function(str) { return /^(\+|-)?\d+(\.\d+)?((e|E)(\+|-)?\d+)?$/.test(str.trim()); }),
parse: shield(function(str) { return parseFloat(str); }),
test: shield(function (str) {
return /^(\+|-)?\d+(\.\d+)?((e|E)(\+|-)?\d+)?$/.test(str.trim());
}),
parse: shield(function (str) {
return parseFloat(str);
}),
description: "No thousand separator, point decimal mark",

@@ -53,8 +74,14 @@ thousand_separator: "",

id: "number$none_point",
example: "12235.56"
example: "12235.56",
};
var point_comma = {
test: shield(function(str) { return /^(\+|-)?\d{1,3}(\.\d{3})*(,\d+)?((e|E)(\+|-)?\d+)?$/.test(str.trim()); }),
parse: shield(function(str) { return parseFloat(str.replace(/\./g, "").replace(/,/, ".")); }),
test: shield(function (str) {
return /^(\+|-)?\d{1,3}(\.\d{3})*(,\d+)?((e|E)(\+|-)?\d+)?$/.test(
str.trim(),
);
}),
parse: shield(function (str) {
return parseFloat(str.replace(/\./g, "").replace(/,/, "."));
}),
description: "Point thousand separator, comma decimal mark",

@@ -64,8 +91,14 @@ thousand_separator: ".",

id: "number$point_comma",
example: "12.235,56"
example: "12.235,56",
};
var space_comma = {
test: shield(function(str) { return /^(\+|-)?\d{1,3}(\s\d{3})*(,\d+)?((e|E)(\+|-)?\d+)?$/.test(str.trim()); }),
parse: shield(function(str) { return parseFloat(str.replace(/\s/g, "").replace(/,/, ".")); }),
test: shield(function (str) {
return /^(\+|-)?\d{1,3}(\s\d{3})*(,\d+)?((e|E)(\+|-)?\d+)?$/.test(
str.trim(),
);
}),
parse: shield(function (str) {
return parseFloat(str.replace(/\s/g, "").replace(/,/, "."));
}),
description: "Space thousand separator, comma decimal mark",

@@ -75,8 +108,12 @@ thousand_separator: " ",

id: "number$space_comma",
example: "12 235,56"
example: "12 235,56",
};
var none_comma = {
test: shield(function(str) { return /^(\+|-)?\d+(,\d+)?((e|E)(\+|-)?\d+)?$/.test(str.trim()); }),
parse: shield(function(str) { return parseFloat(str.replace(/,/, ".")); }),
test: shield(function (str) {
return /^(\+|-)?\d+(,\d+)?((e|E)(\+|-)?\d+)?$/.test(str.trim());
}),
parse: shield(function (str) {
return parseFloat(str.replace(/,/, "."));
}),
description: "No thousand separator, comma decimal mark",

@@ -86,3 +123,3 @@ thousand_separator: "",

id: "number$none_comma",
example: "12235,56"
example: "12235,56",
};

@@ -96,6 +133,6 @@

none_point,
none_comma
none_comma,
]);
number_interpretations.forEach(function(interp) {
number_interpretations.forEach(function (interp) {
interp.type = "number";

@@ -102,0 +139,0 @@ interp.format = getFormatFunction(interp);

import { notAStringError } from "./common.js";
var string_interpretation = Object.freeze({
test: function(str) { return typeof str === "string" ? true : notAStringError(str); },
parse: function(str) { return typeof str === "string" ? str : notAStringError(str); },
format: function(str) { if (typeof str === "string") return str; },
test: function (str) {
return typeof str === "string" ? true : notAStringError(str);
},
parse: function (str) {
return typeof str === "string" ? str : notAStringError(str);
},
format: function (str) {
if (typeof str === "string") return str;
},
type: "string",
description: "Arbitrary string",
id: "string$arbitrary_string"
id: "string$arbitrary_string",
});
export { string_interpretation };

@@ -5,5 +5,10 @@ import { expect } from "chai";

const string_data = [ "a", "b", "c", "d"];
const object_data = [ { letter: "a" }, { letter: "b" }, { letter: "c" }, { letter: "d" }];
const array_data = [ string_data, string_data, string_data, string_data ];
const string_data = ["a", "b", "c", "d"];
const object_data = [
{ letter: "a" },
{ letter: "b" },
{ letter: "c" },
{ letter: "d" },
];
const array_data = [string_data, string_data, string_data, string_data];

@@ -27,3 +32,3 @@ describe("_createAccessorFunction", () => {

it("should return function that behaves the same as the accessor function (with two arguments)", () => {
let f = _createAccessorFunction(d => d.letter);
let f = _createAccessorFunction((d) => d.letter);
expect(object_data.map(f)).to.deep.equal(string_data);

@@ -38,7 +43,12 @@ f = _createAccessorFunction((d, i) => d[i]);

let f = _createAccessorFunction(null);
expect(object_data.map(f)).to.deep.equal([ "undefined", "undefined", "undefined", "undefined" ]);
expect(object_data.map(f)).to.deep.equal([
"undefined",
"undefined",
"undefined",
"undefined",
]);
f = _createAccessorFunction(null);
expect([ { "null": 7 } ].map(f)).to.deep.equal([ "7" ]);
expect([{ null: 7 }].map(f)).to.deep.equal(["7"]);
f = _createAccessorFunction(0);
expect(array_data.map(f)).to.deep.equal([ "a", "a", "a", "a" ]);
expect(array_data.map(f)).to.deep.equal(["a", "a", "a", "a"]);
});

@@ -76,51 +86,131 @@ });

const interpret = createInterpreter();
const checkMatch = function(arr, description) {
const checkMatch = function (arr, description) {
const interpretation = interpret(arr)[0];
if (interpretation.type !== "datetime" || interpretation.description !== description) return false;
var interpreted = arr.map(d => interpretation.format(interpretation.parse(d)));
if (
interpretation.type !== "datetime" ||
interpretation.description !== description
)
return false;
var interpreted = arr.map((d) =>
interpretation.format(interpretation.parse(d)),
);
if (arr.length !== interpreted.length) return false;
return interpreted.every((v, i) => v === arr[i]);
};
const DATE_STRINGS = ["2016-12-03T08:19:56.000Z", "1927-04-03T12:25:32.000Z", "1502-10-21T14:44:28.000Z"];
const DATE_STRINGS = [
"2016-12-03T08:19:56.000Z",
"1927-04-03T12:25:32.000Z",
"1502-10-21T14:44:28.000Z",
];
expect(checkMatch(DATE_STRINGS, "%Y-%m-%dT%H:%M:%S.%LZ")).to.equal(true);
expect(checkMatch(DATE_STRINGS.map(d => d.split("T")[0]), "%Y-%m-%d")).to.equal(true);
expect(checkMatch(["03-12-2016", "03-04-1927", "21-10-1502"], "%d-%m-%Y")).to.equal(true);
expect(checkMatch(["03-12-16", "03-04-27", "21-10-02"], "%d-%m-%y")).to.equal(true);
expect(checkMatch(["12-03-2016", "04-03-1927", "10-21-1502"], "%m-%d-%Y")).to.equal(true);
expect(checkMatch(["12-03-16", "04-03-27", "10-21-02"], "%m-%d-%y")).to.equal(true);
expect(
checkMatch(
DATE_STRINGS.map((d) => d.split("T")[0]),
"%Y-%m-%d",
),
).to.equal(true);
expect(
checkMatch(["03-12-2016", "03-04-1927", "21-10-1502"], "%d-%m-%Y"),
).to.equal(true);
expect(
checkMatch(["03-12-16", "03-04-27", "21-10-02"], "%d-%m-%y"),
).to.equal(true);
expect(
checkMatch(["12-03-2016", "04-03-1927", "10-21-1502"], "%m-%d-%Y"),
).to.equal(true);
expect(
checkMatch(["12-03-16", "04-03-27", "10-21-02"], "%m-%d-%y"),
).to.equal(true);
expect(checkMatch(["12-03", "04-03", "21-10"], "%d-%m")).to.equal(true);
expect(checkMatch(["03-12", "03-04", "10-21"], "%m-%d")).to.equal(true);
expect(checkMatch(["12/03/16", "04/03/27", "10/21/02"], "%m/%d/%y")).to.equal(true);
expect(checkMatch(["03/12/16", "03/04/27", "21/10/02"], "%d/%m/%y")).to.equal(true);
expect(checkMatch(["12/03/2016", "04/03/1927", "10/21/1502"], "%m/%d/%Y")).to.equal(true);
expect(checkMatch(["2016/12/03", "1927/04/03", "1502/10/21"], "%Y/%m/%d")).to.equal(true);
expect(checkMatch(["03/12/2016", "03/04/1927", "21/10/1502"], "%d/%m/%Y")).to.equal(true);
expect(checkMatch(["03-Dec-16", "03-Apr-27", "21-Oct-84"], "%d-%b-%y")).to.equal(true);
expect(
checkMatch(["12/03/16", "04/03/27", "10/21/02"], "%m/%d/%y"),
).to.equal(true);
expect(
checkMatch(["03/12/16", "03/04/27", "21/10/02"], "%d/%m/%y"),
).to.equal(true);
expect(
checkMatch(["12/03/2016", "04/03/1927", "10/21/1502"], "%m/%d/%Y"),
).to.equal(true);
expect(
checkMatch(["2016/12/03", "1927/04/03", "1502/10/21"], "%Y/%m/%d"),
).to.equal(true);
expect(
checkMatch(["03/12/2016", "03/04/1927", "21/10/1502"], "%d/%m/%Y"),
).to.equal(true);
expect(
checkMatch(["03-Dec-16", "03-Apr-27", "21-Oct-84"], "%d-%b-%y"),
).to.equal(true);
expect(checkMatch(["12/16", "04/27", "10/84"], "%m/%y")).to.equal(true);
expect(checkMatch(["12/2016", "04/1927", "10/1502"], "%m/%Y")).to.equal(true);
expect(checkMatch(["03 Dec 2016", "27 Apr 1927", "21 Oct 1502"], "%d %b %Y")).to.equal(true);
expect(checkMatch(["03 December 2016", "27 April 1927", "21 October 1502"], "%d %B %Y")).to.equal(true);
expect(checkMatch(["Dec '16", "Apr '27", "Oct '02"], "%b '%y")).to.equal(true);
expect(checkMatch(["Dec ’16", "Apr ’27", "Oct ’02"], "%b ’%y")).to.equal(true);
expect(checkMatch(["December 3 2016", "April 27 1927", "October 21 1502"], "%B %-d %Y")).to.equal(true);
expect(checkMatch(["03 Dec 16", "27 Apr 27", "21 Oct 02"], "%d %b %y")).to.equal(true);
expect(checkMatch(["03 December 16", "27 April 27", "21 October 02"], "%d %B %y")).to.equal(true);
expect(checkMatch(["Dec 2016", "Apr 1927", "Oct 1502"], "%b %Y")).to.equal(true);
expect(checkMatch(["December 2016", "April 1927", "October 1502"], "%B %Y")).to.equal(true);
expect(checkMatch(["12/2016", "04/1927", "10/1502"], "%m/%Y")).to.equal(
true,
);
expect(
checkMatch(["03 Dec 2016", "27 Apr 1927", "21 Oct 1502"], "%d %b %Y"),
).to.equal(true);
expect(
checkMatch(
["03 December 2016", "27 April 1927", "21 October 1502"],
"%d %B %Y",
),
).to.equal(true);
expect(checkMatch(["Dec '16", "Apr '27", "Oct '02"], "%b '%y")).to.equal(
true,
);
expect(checkMatch(["Dec ’16", "Apr ’27", "Oct ’02"], "%b ’%y")).to.equal(
true,
);
expect(
checkMatch(
["December 3 2016", "April 27 1927", "October 21 1502"],
"%B %-d %Y",
),
).to.equal(true);
expect(
checkMatch(["03 Dec 16", "27 Apr 27", "21 Oct 02"], "%d %b %y"),
).to.equal(true);
expect(
checkMatch(
["03 December 16", "27 April 27", "21 October 02"],
"%d %B %y",
),
).to.equal(true);
expect(checkMatch(["Dec 2016", "Apr 1927", "Oct 1502"], "%b %Y")).to.equal(
true,
);
expect(
checkMatch(["December 2016", "April 1927", "October 1502"], "%B %Y"),
).to.equal(true);
expect(checkMatch(["Dec 16", "Apr 27", "Oct 02"], "%b %y")).to.equal(true);
expect(checkMatch(["03 Dec", "03 Apr", "21 Oct"], "%d %b")).to.equal(true);
expect(checkMatch(["03 December", "03 April", "21 October"], "%d %B")).to.equal(true);
expect(
checkMatch(["03 December", "03 April", "21 October"], "%d %B"),
).to.equal(true);
expect(checkMatch(["2016", "1927", "1502"], "%Y")).to.equal(true);
expect(checkMatch(["December", "April", "October"], "%B")).to.equal(true);
expect(checkMatch(["Dec", "Apr", "Oct"], "%b")).to.equal(true);
expect(checkMatch(["8:19:56 AM", "12:25:32 PM", "2:44:28 PM"], "%X")).to.equal(true);
expect(checkMatch(["08:19 AM", "12:25 PM", "02:44 PM"], "%I:%M %p")).to.equal(true);
expect(
checkMatch(["8:19:56 AM", "12:25:32 PM", "2:44:28 PM"], "%X"),
).to.equal(true);
expect(
checkMatch(["08:19 AM", "12:25 PM", "02:44 PM"], "%I:%M %p"),
).to.equal(true);
expect(checkMatch(["8AM", "12PM", "2PM"], "%-I%p")).to.equal(true);
expect(checkMatch(["08:19", "12:25", "14:44"], "%H:%M")).to.equal(true);
expect(checkMatch(["08:19:05", "12:25:59", "14:44:12"], "%H:%M:%S")).to.equal(true);
expect(checkMatch(["Q1 2016", "Q2 1927", "Q4 2002"], "Q%q %Y")).to.equal(true);
expect(checkMatch(["2016 Q1", "1927 Q2", "2002 Q4"], "%Y Q%q")).to.equal(true);
expect(
checkMatch(["08:19:05", "12:25:59", "14:44:12"], "%H:%M:%S"),
).to.equal(true);
expect(checkMatch(["Q1 2016", "Q2 1927", "Q4 2002"], "Q%q %Y")).to.equal(
true,
);
expect(checkMatch(["2016 Q1", "1927 Q2", "2002 Q4"], "%Y Q%q")).to.equal(
true,
);
expect(checkMatch(["59:56", "00:24", "23:28"], "%M:%S")).to.equal(true);
expect(checkMatch(["12.03.16", "10.28.03", "01.12.79"], "%m.%d.%y")).to.equal(true);
expect(checkMatch(["03.12.2016", "28.10.2003", "12.01.1979"], "%d.%m.%Y")).to.equal(true);
expect(
checkMatch(["12.03.16", "10.28.03", "01.12.79"], "%m.%d.%y"),
).to.equal(true);
expect(
checkMatch(["03.12.2016", "28.10.2003", "12.01.1979"], "%d.%m.%Y"),
).to.equal(true);
});

@@ -132,4 +222,5 @@

const values = ["21 Sept", "09 june", "7 July", "30 Sept"];
const interpretation = createInterpreter.getInterpretation("datetime$%d %b");
expect(values.every(d => interpretation.test(d))).to.equal(true);
const interpretation =
createInterpreter.getInterpretation("datetime$%d %b");
expect(values.every((d) => interpretation.test(d))).to.equal(true);
});

@@ -139,4 +230,5 @@

const values = ["40 Sept", "31 june", "-37 July", "99 Sept"];
const interpretation = createInterpreter.getInterpretation("datetime$%d %b");
expect(values.every(d => interpretation.test(d))).to.equal(false);
const interpretation =
createInterpreter.getInterpretation("datetime$%d %b");
expect(values.every((d) => interpretation.test(d))).to.equal(false);
});

@@ -148,4 +240,5 @@ });

const values = ["Sept 14", "june 05", "July 6", "Sept 10"];
const interpretation = createInterpreter.getInterpretation("datetime$%b %d");
expect(values.every(d => interpretation.test(d))).to.equal(true);
const interpretation =
createInterpreter.getInterpretation("datetime$%b %d");
expect(values.every((d) => interpretation.test(d))).to.equal(true);
});

@@ -155,4 +248,5 @@

const values = ["Sept 111", "june 31", "July 99", "Oct -1"];
const interpretation = createInterpreter.getInterpretation("datetime$%b %d");
expect(values.every(d => interpretation.test(d))).to.equal(false);
const interpretation =
createInterpreter.getInterpretation("datetime$%b %d");
expect(values.every((d) => interpretation.test(d))).to.equal(false);
});

@@ -164,12 +258,45 @@ });

const interpret = createInterpreter();
const checkMatch = function(arr, description) {
const checkMatch = function (arr, description) {
const interpretation = interpret(arr)[0];
return interpretation.type === "number" && interpretation.description === description;
return (
interpretation.type === "number" &&
interpretation.description === description
);
};
expect(checkMatch(["-787", "1,246.83", "203", "1,340,201"], "Comma thousand separator, point decimal mark")).to.equal(true);
expect(checkMatch(["-787", "1 246.83", "203", "1 340 201"], "Space thousand separator, point decimal mark")).to.equal(true);
expect(checkMatch(["-787", "1246.83", "203", "1340201"], "No thousand separator, point decimal mark")).to.equal(true);
expect(checkMatch(["-787", "1.246,83", "203", "1.340.201"], "Point thousand separator, comma decimal mark")).to.equal(true);
expect(checkMatch(["-787", "1 246,83", "203", "1 340 201"], "Space thousand separator, comma decimal mark")).to.equal(true);
expect(checkMatch(["-787", "1246,83", "203", "1340201"], "No thousand separator, comma decimal mark")).to.equal(true);
expect(
checkMatch(
["-787", "1,246.83", "203", "1,340,201"],
"Comma thousand separator, point decimal mark",
),
).to.equal(true);
expect(
checkMatch(
["-787", "1 246.83", "203", "1 340 201"],
"Space thousand separator, point decimal mark",
),
).to.equal(true);
expect(
checkMatch(
["-787", "1246.83", "203", "1340201"],
"No thousand separator, point decimal mark",
),
).to.equal(true);
expect(
checkMatch(
["-787", "1.246,83", "203", "1.340.201"],
"Point thousand separator, comma decimal mark",
),
).to.equal(true);
expect(
checkMatch(
["-787", "1 246,83", "203", "1 340 201"],
"Space thousand separator, comma decimal mark",
),
).to.equal(true);
expect(
checkMatch(
["-787", "1246,83", "203", "1340201"],
"No thousand separator, comma decimal mark",
),
).to.equal(true);
});

@@ -179,3 +306,3 @@

const interpret = createInterpreter();
const checkMethod = function(prop, default_value, new_value) {
const checkMethod = function (prop, default_value, new_value) {
var func = interpret[prop];

@@ -197,5 +324,14 @@ if (func() !== default_value) return false;

const DEFAULT_YEAR = 1900;
const checkMatch = function(format_string, date_as_string, year = DEFAULT_YEAR) {
const checkMatch = function (
format_string,
date_as_string,
year = DEFAULT_YEAR,
) {
const id = "datetime$" + format_string;
expect(createInterpreter.getInterpretation(id).parse(date_as_string).getFullYear()).to.equal(year);
expect(
createInterpreter
.getInterpretation(id)
.parse(date_as_string)
.getFullYear(),
).to.equal(year);
};

@@ -244,2 +380,5 @@ checkMatch("%Y-%m-%dT%H:%M:%S.%LZ", "2016-12-03T08:19:56.000Z", 2016);

checkMatch("%d.%m.%Y", "03.12.2016", 2016);
checkMatch("%YM%m", "2016M12", 2016);
checkMatch("%YQ%q", "2016Q4", 2016);
checkMatch("%YÁ%q", "2016Á4", 2016);
});

@@ -249,3 +388,3 @@

var datetime_ids = createInterpreter.DATETIME_IDS;
datetime_ids.forEach(id => {
datetime_ids.forEach((id) => {
const interpretation = createInterpreter.getInterpretation(id);

@@ -259,5 +398,7 @@ expect(interpretation.parse("") === null).to.equal(true);

var datetime_ids = createInterpreter.DATETIME_IDS;
datetime_ids.forEach(id => {
datetime_ids.forEach((id) => {
const interpretation = createInterpreter.getInterpretation(id);
expect(values.every(d => interpretation.parse(d) === null)).to.equal(true);
expect(values.every((d) => interpretation.parse(d) === null)).to.equal(
true,
);
});

@@ -269,3 +410,4 @@ });

it("should parse the empty string as null", () => {
const interpreter = createInterpreter.getInterpretation("number$comma_point");
const interpreter =
createInterpreter.getInterpretation("number$comma_point");
expect(interpreter.parse("")).to.be.null;

@@ -275,3 +417,4 @@ });

it("should parse non-empty strings that do not represent numbers as NaN", () => {
const interpreter = createInterpreter.getInterpretation("number$comma_point");
const interpreter =
createInterpreter.getInterpretation("number$comma_point");
expect(interpreter.parse("#NULL")).to.be.NaN;

@@ -288,3 +431,3 @@ expect(interpreter.parse("Hello, world!")).to.be.NaN;

expect(!!ids.length).to.equal(true);
expect(ids.every(d => typeof d === "string")).to.equal(true);
expect(ids.every((d) => typeof d === "string")).to.equal(true);
});

@@ -298,3 +441,3 @@ });

expect(!!ids.length).to.equal(true);
expect(ids.every(d => typeof d === "string")).to.equal(true);
expect(ids.every((d) => typeof d === "string")).to.equal(true);
});

@@ -308,3 +451,3 @@ });

expect(!!ids.length).to.equal(true);
expect(ids.every(d => typeof d === "string")).to.equal(true);
expect(ids.every((d) => typeof d === "string")).to.equal(true);
});

@@ -314,3 +457,5 @@ });

describe("createInterpreter.getInterpretation", () => {
const checkMethod = function(id) { return createInterpreter.getInterpretation(id).id === id; };
const checkMethod = function (id) {
return createInterpreter.getInterpretation(id).id === id;
};

@@ -320,3 +465,5 @@ describe("when the id argument does not match a recognised id", () => {

expect(createInterpreter.getInterpretation()).to.equal(undefined);
expect(createInterpreter.getInterpretation("ABCDEFG")).to.equal(undefined);
expect(createInterpreter.getInterpretation("ABCDEFG")).to.equal(
undefined,
);
});

@@ -327,3 +474,5 @@ });

it("should return the interpeter object with the right id", () => {
createInterpreter.NUMBER_IDS.forEach(d => expect(checkMethod(d)).to.equal(true));
createInterpreter.NUMBER_IDS.forEach((d) =>
expect(checkMethod(d)).to.equal(true),
);
});

@@ -334,3 +483,5 @@ });

it("should return the interpeter object with the right id", () => {
createInterpreter.DATETIME_IDS.forEach(d => expect(checkMethod(d)).to.equal(true));
createInterpreter.DATETIME_IDS.forEach((d) =>
expect(checkMethod(d)).to.equal(true),
);
});

@@ -341,3 +492,5 @@ });

it("should return the interpeter object with the right id", () => {
createInterpreter.STRING_IDS.forEach(d => expect(checkMethod(d)).to.equal(true));
createInterpreter.STRING_IDS.forEach((d) =>
expect(checkMethod(d)).to.equal(true),
);
});

@@ -344,0 +497,0 @@ });

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