[TW5] Doing Math and Comparisons

193 views
Skip to first unread message

Dylan Kinnett

unread,
Nov 15, 2013, 7:18:21 PM11/15/13
to tiddl...@googlegroups.com
This may be completely from outer space, especially for an Alpha, but I was curious:

Is it possible, or would it make sense for it to become possible, to do any kind of math or comparison via the List Widget's filter abilities or some other method(s)? Here are a couple of use cases I can think of, from the project I'm working on. If any of these things are better done via other methods, I'm curious to learn them.

1. list all tiddlers who have a field value that is equal to one of the field values within the current tiddler.

2. if a tiddler has two fields that are dates, can those two dates be compared to each other? In my case, specifically, I'm interested in counting the number of days between the two dates (or between one of the dates and the current date).

Jeremy Ruston

unread,
Nov 16, 2013, 3:40:34 AM11/16/13
to TiddlyWiki
1. list all tiddlers who have a field value that is equal to one of the field values within the current tiddler.

We can do this already. Recall that you can indirect the argument to any filter operator through a tiddler like this:

[myFieldName{tiddlerContainingComparisonValue!!field}]

That example gives you all tiddlers that have the field "myFieldName" set to the same value as the content of the tiddler "tiddlerContainingComparisonValue".
 
2. if a tiddler has two fields that are dates, can those two dates be compared to each other? In my case, specifically, I'm interested in counting the number of days between the two dates (or between one of the dates and the current date).

One approach would be extend the filter syntax to allow comparisons:

[filter<[value]]
[filter=[value]]
[filter>[value]]
[filter<=[value]]
[filter=>[value]]
 
There's no obvious approach to display the duration of the interval between two dates. It may be that the simplest thing would be a new widget:

<$age date1="tiddler!!field" date2="tiddler2!!field2"/>

Would those two proposals be enough to keep you going?

Best wishes

Jeremy

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/groups/opt_out.



--
Jeremy Ruston
mailto:jeremy...@gmail.com

Dylan Kinnett

unread,
Nov 17, 2013, 5:49:12 PM11/17/13
to tiddl...@googlegroups.com
Yes I think those two proposals are enough to keep me going. I'll try the first approach you mentioned, in the upcoming days. 

To the filters you proposed for allowing comparisons, I would only suggest the addition of a "not equals" syntax.

As for comparing dates, that example widget looks like it would be useful. 

I did some searching online, and I don't know how relevant this is but I found a discussion on stack overflow  that mentions a small javascript utility for comparing dates in several ways.
Reply all
Reply to author
Forward
0 new messages