Commit ffa426ec authored by Themousaillon's avatar Themousaillon

fix for the negative year bug

parent f60091c6
......@@ -192,6 +192,18 @@ module.exports = function () {
};
Frame.prototype.getFilter = function () {
const formatDate = str => {
let yearSign = "+"
let [day, month, year] = str.split(" ")
if (year[0] === "-")
yearSign = "-"
year = year.replace("-", "")
// we need to make year a six digit number in order to be able to ECMA strings for negative time (BC)
const ecma = 5 - Math.floor(Math.log(parseInt(year)) / Math.LN10)
const addedZeros = Array(ecma).fill("0").join().replace(/,/g, "")
return yearSign + addedZeros + year + " " + month + " " + day
}
let filter = {};
this.app.settings.source.properties.forEach((property) => {
let option = this.app.settings.source.options[property];
......@@ -201,7 +213,7 @@ module.exports = function () {
case "date":
let elem = document.getElementById(id + '-slider');
if (!!elem && !!elem.noUiSlider) {
let dates = elem.noUiSlider.get();
let dates = elem.noUiSlider.get().map(s => formatDate(s));
filter[property] = {
type: "date",
start: new Date(dates[0]),
......
......@@ -104,6 +104,7 @@ module.exports = (function () {
let d0 = f.start;
let d1 = f.end;
let date = new Date(resource[property]);
// ???????? division seems completely useless here
if (d0.getTime()/1000>date.getTime()/1000 || date.getTime()/1000>=d1.getTime()/1000) {
return false;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment