I record a daily journal using the Journal button which makes a new tiddler with the “Journal” tag. I was interested in making a weekly summary but realized that filter for that would be very difficult.
Does anyone know how I could make a filter that will show the tiddlers tagged as Journal created last week–that is monday - friday of last week thus the relative time period only changes once a week?
I’ve poked around and I am fairly sure it’s next to impossible without using JavaScript. Let’s see what we’d need to get it done:
Determine the date of last Monday
You can get it by determining Monday in current week and subtract 7
You could use <<now "dddd">> to get 1-indexed day of the week. Subtract 1 from it and you have the number of days you have to subtract from current date to get Monday. Let’s call it SUBTRACTO
You could use <<now "DD">> to get current day of the month. If you subtract SUBTRACTO from it, you will have the day of the month for current Monday.
Great! Except what if it results in 0 or a negative number? Then you could use <<now "MM">> and subtract 1 from it to rollunder the month and then…
Then you need a lookup table of days in a month (but also keep in mind to check the year for leap years for February). Start from that value and subtract the number from previous point to get the day of the month.
Repeat for year rollunder, in case you started in January…
Then you’d need to repeat the whole process, subtracting 7 more from that.
Then convert both to TW’s modified/created format.
It’s all technically possible but because TW’s filters don’t support conditionals whatever you end up with is going to be a monster of a filter .
Keep in mind there is a week number date format and you can test it for each date the week number it has. Then you can also test day of week to seperate weekends.
The days operator can be used for last 7 days as can be the use of unix time.
More one or more days operators can generate ranges.
Also so long as you handle year changes, day of year is useful as well.
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.