This commit is contained in:
2020-03-04 15:42:20 +00:00
parent c9ae62ec6c
commit f43e4e8d88
2 changed files with 35 additions and 4 deletions

View File

@@ -3,8 +3,8 @@
/*
{ name: vm.lt("DateRangeTomorrow"), id: "*tomorrow*" },
{ name: vm.lt("DateRangeLastWeek"), id: "*lastweek*" },
{ name: vm.lt("DateRangeTomorrow"), id: "**" },
{ name: vm.lt("DateRangeLastWeek"), id: "**" },
{ name: vm.lt("DateRangeThisWeek"), id: "*thisweek*" },
{ name: vm.lt("DateRangeNextWeek"), id: "*nextweek*" },
{ name: vm.lt("DateRangeLastMonth"), id: "*lastmonth*" },
@@ -68,6 +68,37 @@ export default {
.toUTC()
.toString();
break;
case "*tomorrow*":
//Between Tonight at midnight and day after tommorow at midnight
ret.after = dtToday
.plus({ days: 1, seconds: -1 })
.toUTC()
.toString();
ret.before = dtToday
.plus({ days: 2 })
.toUTC()
.toString();
break;
case "*lastweek*":
//Between two Sundays ago at midnight and last sunday at midnight
//go back a week
var dtAfter = dtToday.plus({ days: -7 });
//go backwards to Sunday (In Luxon Monday is 1, Sunday is 7)
while (dtAfter.weekday != 7) {
console.log("dow:" + dtAfter.weekday + ", is " + dtAfter.weekdayLong);
dtAfter = dtAfter.plus({ days: -1 });
}
//go to very start of eighth dayahead
var dtBefore = dtAfter.plus({ days: 8 });
//remove a second for boundary
dtAfter = dtAfter.plus({ seconds: -1 });
//set return values from calculated values
// ret.after = dtAfter.toUTC().toString();
// ret.before = dtBefore.toUTC().toString();
ret.after = dtAfter.toString();
ret.before = dtBefore.toString();
break;
}
return ret;

View File

@@ -924,7 +924,7 @@ function untokenizeListView(lv) {
//iterate the array and build a new array with substituted tokens with the correct date and time in them
console.log(lv);
//console.log(JSON.parse(lv));
console.log("test:yesterday");
console.log(relativeDatefilterCalculator.tokenToDates("*yesterday*"));
console.log("test:lastweek");
console.log(relativeDatefilterCalculator.tokenToDates("*lastweek*"));
}
</script>