I can do it in JS… although with a full week, monday - sunday. I don’t know how to do it in wikitext except to try to follow @Maurycy’s steps above.
We can use something like this:
/*\
title: $:/my/modules/filters/priorweek.js
type: application/javascript
module-type: filteroperator
Filter operator that selects tiddlers with a created date field in the week preceding today (or other given number of weeks prior).
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Export our filter function
*/
exports.priorweek = function(source,operator,options) {
var results = [],
fieldDay = null,
fieldName = (operator.suffixes || [])[0] || "created",
weeks = $tw.utils.parseNumber(operator.operand || "1"),
now = new Date(),
startDate = new Date(now.getFullYear(), now.getMonth(), now.getDate() - (7 * weeks - 1 + ((now.getDay() % 7) || 7))),
endDate = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 7 - (7 * weeks - 1 + ((now.getDay() % 7) || 7)));
source(function(tiddler,title) {
if(tiddler) {
fieldDay = tiddler.getFieldDay(fieldName);
if(fieldDay >= startDate && fieldDay < endDate) {
results.push(title);
}
}
});
return results;
};
})();
and use it like this:
<<list-links filter:"[tag[Journal]priorweek[]!sort[created]]">>
for last weeks tiddlers (by created
date)
or
<<list-links filter:"[tag[Journal]priorweek[2]!sort[created]]">>
for the week before last, and so on.
Or you could choose to use the modified
field by adding a suffix:
<<list-links filter:"[tag[Journal]priorweek:modified[]!sort[modified]]">>
To use it, you can download this and drag the resulting file onto your wiki: priorweek.json (1.3 KB) You will have to save and reload before it takes effect.