I am trying to write a forEachTiddler script to display any tiddlers
that are tagged with today's date.  In all my work I use a custom date
format Year, Month, Day, with leading zeros (as in 20101117, the date
of this post).

I've almost got it working!  Here is my script.


<<forEachTiddler
    sortBy
        'tiddler.created'
        descending

    script
        '
        function lastDays(tiddler) {
                var currentTime = new Date()
                var month = currentTime.getMonth() + 1
                var day = currentTime.getDate()
                        if (day<10)
                                {
                                day = "0" + day;
                                }
                var year = currentTime.getFullYear()
                year = year.toString();
                day = day.toString();
                month = month.toString();
                var today = (year + day + month)

    if (tiddler.tags.contains(today))
                return "* [[" + tiddler.title + "]]\n";
            else
                return "";
}
        '
    write 'lastDays(tiddler)'
>>

The issue is that the line
   if (tiddler.tags.contains(today))
doesn't reference the variable "today".
It works if I hardcode a date in there.  And I know that the "today"
variable is outputting in the correct format.  I just don't know how
to get the variable "today" into tiddler.tags.contains().

any help is very much appreciated!  I did my homework on this but I'm
definitely a beginner at javascript.  If there is an obvious shortcut
to this function I've overlooked, please do enlighten me.

Thanks TW dev group!

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en.

Reply via email to