@flourish/interpreter
Advanced tools
Comparing version 8.4.0 to 8.5.0
@@ -1041,2 +1041,17 @@ (function (global, factory) { | ||
}), | ||
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); | ||
}), | ||
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])); | ||
}), | ||
createDatetimeInterpretation("%m-%d-%Y", function(str, passed_primary_test) { // 04-27-1972 | ||
@@ -1143,4 +1158,9 @@ if (!passed_primary_test) return false; | ||
createDatetimeInterpretation("%-I.%M%p"), // 7.45PM | ||
createDatetimeInterpretation("%H:%M"), // 19:45 | ||
createDatetimeInterpretation("%H:%M", function(str, passed_primary_test) { // 19:45 | ||
if (!passed_primary_test) return false; | ||
var arr = str.split(":").map(parseFloat); | ||
return arr[0] >= 0 && arr[0] < 24; | ||
}), | ||
createDatetimeInterpretation("%H:%M:%S"), // 19:45:05 | ||
createDatetimeInterpretation("%M:%S"), // 45:05 | ||
createDatetimeInterpretation("%-I%p"), // 7PM | ||
@@ -1147,0 +1167,0 @@ |
{ | ||
"name": "@flourish/interpreter", | ||
"version": "8.4.0", | ||
"version": "8.5.0", | ||
"private": false, | ||
@@ -8,2 +8,10 @@ "description": "Does a best guess at the type of data supplied", | ||
"module": "src/index.js", | ||
"scripts": { | ||
"build": "rollup -c", | ||
"lint": "eslint src", | ||
"minify": "uglifyjs -m -o interpreter.min.js interpreter.js", | ||
"prepare": "npm run build && npm run minify", | ||
"pretest": "npm run build", | ||
"test": "mocha" | ||
}, | ||
"author": "Kiln Enterprises Ltd", | ||
@@ -27,10 +35,3 @@ "license": "LicenseRef-LICENSE", | ||
"uglify-js": "^3.6.4" | ||
}, | ||
"scripts": { | ||
"build": "rollup -c", | ||
"lint": "eslint src", | ||
"minify": "uglifyjs -m -o interpreter.min.js interpreter.js", | ||
"pretest": "npm run build", | ||
"test": "mocha" | ||
} | ||
} | ||
} |
@@ -0,1 +1,4 @@ | ||
# 8.5.0 | ||
* Add "%d.%m.%Y", "%m.%d.%y" and "%M:%S" datetime formats | ||
# 8.4.0 | ||
@@ -2,0 +5,0 @@ * Add "%b '%y" and "%B %-d %Y" datetime formats |
@@ -1,4 +0,4 @@ | ||
import { datetime_interpretations } from "./types/datetime"; | ||
import { number_interpretations } from "./types/number"; | ||
import { string_interpretation } from "./types/string"; | ||
import { datetime_interpretations } from "./types/datetime.js"; | ||
import { number_interpretations } from "./types/number.js"; | ||
import { string_interpretation } from "./types/string.js"; | ||
@@ -5,0 +5,0 @@ var INTERPRETATION_OPTIONS = Object.freeze({ |
import { utcParse, utcFormat } from "d3-time-format"; | ||
import { shield } from "./common"; | ||
import { shield } from "./common.js"; | ||
@@ -135,2 +135,17 @@ var EXAMPLE_DATETIME = new Date(1972, 3, 27, 19, 45, 5); // End of Apollo 16 mission | ||
}), | ||
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); | ||
}), | ||
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])); | ||
}), | ||
createDatetimeInterpretation("%m-%d-%Y", function(str, passed_primary_test) { // 04-27-1972 | ||
@@ -237,4 +252,9 @@ if (!passed_primary_test) return false; | ||
createDatetimeInterpretation("%-I.%M%p"), // 7.45PM | ||
createDatetimeInterpretation("%H:%M"), // 19:45 | ||
createDatetimeInterpretation("%H:%M", function(str, passed_primary_test) { // 19:45 | ||
if (!passed_primary_test) return false; | ||
var arr = str.split(":").map(parseFloat); | ||
return arr[0] >= 0 && arr[0] < 24; | ||
}), | ||
createDatetimeInterpretation("%H:%M:%S"), // 19:45:05 | ||
createDatetimeInterpretation("%M:%S"), // 45:05 | ||
createDatetimeInterpretation("%-I%p"), // 7PM | ||
@@ -241,0 +261,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { shield } from "./common"; | ||
import { shield } from "./common.js"; | ||
import { formatLocale } from "d3-format"; | ||
@@ -3,0 +3,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { notAStringError } from "./common"; | ||
import { notAStringError } from "./common.js"; | ||
@@ -3,0 +3,0 @@ |
const { expect } = require("chai"); | ||
const { createInterpreter } = require("../interpreter"); | ||
const { createInterpreter } = require("../interpreter.js"); | ||
const _createAccessorFunction = createInterpreter._createAccessorFunction; | ||
@@ -109,2 +109,5 @@ | ||
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); | ||
}); | ||
@@ -218,2 +221,5 @@ | ||
checkMatch("%Y Q%q", "2016 Q3", 2016); | ||
checkMatch("%M:%S", "19:56"); | ||
checkMatch("%m.%d.%y", "12.03.16", 2016); | ||
checkMatch("%d.%m.%Y", "03.12.2016", 2016); | ||
}); | ||
@@ -220,0 +226,0 @@ |
108345
2231