Days Operator and Examples (documentation addition)

403 views
Skip to first unread message

TonyM

unread,
Sep 6, 2018, 11:31:11 PM9/6/18
to TiddlyWiki

Folks,


I am hopping to expand the documentation on the days operator on TiddlyWiki.com, in this case I do not understand it myself, So I am reaching out to the community. Have you worked it out yourself, can you provide some information to help.


Could someone please Expand the Documentation to better document its function including giving examples of each +ve -ve and ! combinations and ideally a range.

I have not worked it out properly yet, but here are some details of what to include

  • Every tiddler with the date field up to a particular date in the future
  • Every tiddler with the date field after a particular date in the future
  • Every tiddler with the date field back to a particular date in the past
  • Every tiddler with the date field before a particular date in the past

And using two days operators to

  • select a date between two dates
  • Show date outside a range of dates or not between two dates

Thanks in advance

TonyM

unread,
Sep 7, 2018, 9:10:33 PM9/7/18
to tiddl...@googlegroups.com
Bump,

I will do this myself if I must, but I would prefer some reference materials by people who have used the days operator more than me.

Can you share some example code snipits where you have used it. Perhaps with a little annotation?

Thanks
Tony

Mark S.

unread,
Sep 7, 2018, 9:29:50 PM9/7/18
to TiddlyWiki
Side note: Your timestamp says that you posted 21 hours ago, but I'm pretty sure I didn't see this in the feed until just now. So maybe Guugle delayed it for some reason and others are also just seeing it now.

-- Mark

TonyM

unread,
Sep 8, 2018, 4:48:33 AM9/8/18
to TiddlyWiki
Folks,

Since the title of this Post may attract people looking for the  Days Operator and Examples (documentation addition)
and since I have not had any reply's so far I have gone ahead and researched this. I have attached a tiddler I used to understand the days operator for anyone interested.

To be honest this days operator may have some advantages in some coding cases, and it provides the features we need it really confuses the user. But I expect that why I got no replies is because almost no one understands it.

I will prepare a more refined set of examples and documentation however it will be quite tricky. Here are some conceptual ideas to keep in mind if you want to use it yourself. 

This is my conclusion but needs independent verification.

When using the days parameter the number N in days[N] and days[-N] is always a date relative to today (Negative in the past, and Positive in the future) and today is always important.
You can specify a field other than modified with days:fieldname[N]. The meaning of N never changes It is the point around which you are looking for dates.

Let us call the date referenced by the number a "Reference date", and they are relative to today

Now the Positive form of the days operator is "days[n]" and the negative  form "!days[N]"

First Using Zero for N
If N = 0 days[0] in the positive form means all days in the past and future for the nominated date field.
If N = 0 !days[0] in the negative form means NO days in the past or future for the nominated date field. Always no days at all.

The Positive or negative forms can be considered as 
  • Positive includes today The positive form means always include today in the result
  • Negative does not include today The negative form means do not include today in the result
Basically if you have today and a reference date say 7 or -7 days from now then (regardless of whether the reference date is + or -);
  • The positive form will give you all days from the reference date, including today so it will be all dates before the reference date (into the past)
  • The negative form will give you all days from the reference date, Not including today for it will be all dates after the reference date (into the future)
If you want all days in the future of a given date
it all depends on when today is

For Future reference dates Use the days operator !days[+N]
For Past reference dates Use the days operator days[-N]

If you want all days in the past of a given date
it all depends on when today is

For Future reference dates Use the days operator days[+N]
For Past reference dates Use the days operator !days[-N]

Remember ! is like Not, and Not including today


Using a range of dates, using the same date field and two days operators

Use the convention of the past date first and future date second days[-7]days[+7]
  • Use the positive or negative version of the days operator but do NOT Mix them
    to mix them will either mean one is not necessary or the result is null
  • The Positive (on both days operators) version will be the dates between the two reference dates. 
  • The Negative (on both days operators) version will be the dates Outside the two reference dates. 
Regards
Tony
Understand the days Operator.tid

RA

unread,
Sep 9, 2018, 7:49:04 PM9/9/18
to TiddlyWiki
Please see this post for explanation and examples. The patch mentioned there has been merged so everything should work as described.

TonyM

unread,
Sep 9, 2018, 8:30:49 PM9/9/18
to TiddlyWiki
RA,

Thanks for your response. Can you confirm my interpretations based here make sense?.
I am basically hoping to improve the documentation, not simply understand it.

I have currently also a draft table that may help, perhaps you could check it? Attached as a Tid

Regards
Tony

10th September 2018 at 10:29am

Name Relative/reference date "days[N]" "!days[N]" Only
Yesterday days[-1] days[-1] Yesterday and all days into the future !days[-1]Yesterday and all days into the past Yesterday only days[-1]!days[-1] XXX
Today days[0] days[0] Today only !days[0] Not today (all other days) Today only days[0]
Tomorrow days[+1] days[+1] Tomorrow and All days in the past !days[+1]Tomorrow and all days in the future Tomorrow only days[+1]!days[+1] XXX
A past day days[-7] days[-7] 7 days ago and all days in the future !days[-7] 7 days ago and all days in the past A past day only days[-7]!days[-7] XXX
A future day days[+7] days[+7] 7 days ahead and all days in the past !days[+7] 7 days ahead and all days in the future A future day only days[+7]!days[+7] XXX

Still to come
  • Older than today
  • After today
  • Before today
  • Later than today

Name Relative/reference date "days[N]" "!days[N]" Notes
A Range of Dates

Today is 0 gives today only and its negation gives Not today (all other dates)
Tomorrow is +1 gives Tomorrow and all days before into the past and its negation gives Tomorrow and all days intot the future

"Yesterday is -1 

Days reference_relative dates.tid

Dave

unread,
Nov 4, 2018, 8:48:12 PM11/4/18
to TiddlyWiki
Just for reference, here is an Agenda based on the days operator that *mostly* works

<ul>
  <$list filter="[has[due]days:due[60]days:due[-60]!sort[due]]">
   
<li>
      <$link><$view field="title"/></$link>
         <$list filter="[
<currentTiddler>days:due[15]!days:due[2]]"> @@color:beige;^^upcoming^^@@</$list>
         <$list filter="[
<currentTiddler>days:due[1]days:due[-1]]"> @@color:red;^^today^^@@</$list>
         <$list filter="[
<currentTiddler>days:due[-7]!days:due[-2]]"> @@color:black;^^recent^^@@</$list>
         <$list filter="[
<currentTiddler>days:due[-60]!days:due[-30]]"> @@color:yellow;^^over a month^^@@</$list>
   
</li>
  </$list>
</ul>
This lists all the tiddlers that have 20181104 type dates in the "due" field.  The only glitch is that it includes tomorrow and today as  "today" in the labelling.  I tried days:due[0]days:due[0]] but that didn't work.

It lists all tiddlers with a due date 2 months into the future and past.

see attached pic

AgendaTW5.png

RA

unread,
Nov 4, 2018, 9:42:46 PM11/4/18
to TiddlyWiki
It's not a glitch. `days:due[1]days:due[-1]` is the intersection of "tomorrow and anything older" and "yesterday and anything newer". Today is just `days:due[0]`. Now please have a look at this issue https://github.com/Jermolene/TiddlyWiki5/issues/2061 and you'll realize that this filter is of limited usability because of how TW handles dates. `days:due[0]` shows tiddlers that are due "today in UTC". For me in PST, that means at 5PM it starts returning tomorrow's date as "today". This shift applies to `days:due[1]days:due[-1]` as well, and any other use of `days` filter.

RA

unread,
Nov 6, 2018, 3:41:41 AM11/6/18
to TiddlyWiki
Looked at it some more and I think "days" operator is not working properly anymore. Here is my test, I'm sure it worked 100% before. (To demo all the test cases, it needs 13 tiddlers with "due" field set to each day from today-6 to today+6.)

```
today:
<<list-links '[days:due[]]'>>
4 days ago:
<<list-links '[days:due[-4]!days:due[-4]]'>>
<<list-links '[days:due[-4]] -[days:due[-3]]'>>
last 5 days:
<<list-links '[days:due[-5]!days:due[-1]sort[due]]'>>
next 5 days:
<<list-links '[!days:due[1]days:due[5]sort[due]]'>>
day before:
<<list-links '[days:due[-2]] -[days:due[-1]]'>>
yesterday:
<<list-links '[days:due[-1]] -[days:due[]] -[!days:due[1]]'>>
yesterday:
<<list-links '[days:due[-1]!days:due[-1]]'>>
tomorrow:
<<list-links '[!days:due[1]days:due[1]]'>>
tomorrow:
<<list-links '[!days:due[1]] -[!days:due[2]]'>>
day after:
<<list-links '[!days:due[2]] -[!days:due[3]]'>>

---
everything:
<<list-links '[!due[]sort[due]]'>>
```
Reply all
Reply to author
Forward
0 new messages