Tiddlytools/Time/Calendar - Help with Events

Hi @EricShulman

I have a Tiddlywiki which I use as a diary, where entries are individual tiddlers tagged with Journal, and for listing future appointments/events, which are individual tiddlers tagged with Event.

I am using Tiddlytools/Time/Calendar to create the entries. Journal entries appear in the Calendar.

Please can you tell me how I can get the appointments to show up in the Calendar. I propose to use an Event List for recurring events but would prefer to keep the appointments as individual tiddlers.

How can this be done?

Cheers, Rob

1 Like

Event List tiddlers (tagged with events) typically contain lines of text using the YYYYMMDD;description format. For example, to define a few recurring annual events, you can write:

....0101;Happy New Year!
....1031;Boo!
....1225;Merry Christmas

But, Event List tiddlers can also contain ANY wikitext syntax that outputs lines in the above format. For your use-case, just add the following line of wikitext code to the end of your Event List tiddler:

<$list filter="[tag[Appointment]] [tag[Event]]">{{!!text}}<br></$list>

Then, you can create as many tiddlers as you like, each tagged with Appointment or Event, where the text content of each those tiddlers is a single line using the YYYYMMDD;description format, and those dates/descriptions will automatically be included in the Event List.

enjoy,
-e

1 Like

@EricShulman Many thanks for the advice and for the explanation. The latter is always very useful in developing a better understanding of how things work.

I created an Event List tiddler as advised with the wikitext code. The Event List shows all of the tiddlers tagged with Event but they do not appear in the Calendar. When I created a second Event List tiddler and pasted the Event tiddlers into that as text they all appear in the Calendar as intended! Any explanation for this?

Also in the latter case whren I click in the Event in a pop-up window in the Calendar the Event tiddler does not exist. Could there be something wrong with the way I am naming the Event tiddlers?

Cheers, Rob

Can you post exactly what each of those Event List tiddlers contains?

For the first Event List you created, it shouldn’t “show all the tiddlers tagged with Event” (i.e., their titles)… but rather it should show the text content from each of those tiddlers, one per line. Note also that when you create a new Event List, in order for it to appear in the calendar you must also select that Event List in the calendar setup (the “gear” button above the calendar display).

If you click on the text of an event in a Calendar popup, it opens a tiddler whose title is the text of the event itself. This gives you the ability to enter notes related to the event. If you click on the color square next to an event in the Calendar popup, it opens the Event List tiddler in which that event is defined.

-e

Hi @EricShulman

I attach two json files, one with the Event List tiddlers and one with the Event Tiddlers.

Event Lists.json (929 Bytes)
Event tiddlers.json (2.3 KB)

The Event List with the wiki text does show the text content from each of the event tiddlers. Also I have checked the box for the Event List in the Calendar popup. But the events from Events List given color Bisque do not show up at the bottom of the particular day in the Calendar ( as do the events fromEvents List 2!)

I hope this all helps to solve the problem.

Cheers, Rob

wow… this was subtle… the problem was with how the list of events was being generated by the $list widget in “Events List”. In order for it to work, the TiddlyTools calendar getevents_listed() macro uses a $wikify widget to process the “Events List” contents, and then depends upon being able to detect newlines in that output in order to split the result into separate event items.

The directions I previously gave said to write something like this:

<$list filter="[tag[Event]]">{{!!text}}<br></$list>

but that doesn’t work because, while there are <br> HTML line breaks between items, there aren’t actually any literal newline characters in the output, so all the events ran together and only the first event (20241121;Oak Furnitureland Delivery) was being recognized and displayed in the Calendar.

Instead, you need to write:

<$list filter="[tag[Event]]">
{{!!text}}<br>
</$list>

which DOES contain literal newlines in the output. Using the above wikitext code, all the items will successfully appear in the Calendar display… except for “2025-02-20: My Birthday”, which doesn’t have any text field contents so it is omitted from the Calendar display.

However, I notice that each of your individual event tiddlers (including your birthday event) also has a date field (using YYYYMMDD format) and a title that contains the description of the event. Thus, instead of the above wikitext code, you could use this:

<$list filter="[tag[Event]]">
{{!!date}};{{!!title}}<br>
</$list>

which doesn’t rely upon the text field contents. Using this wikitext code, ALL of your individual event tiddlers will appear in the Calendar… and, it has the added advantage of leaving the text field of each event tiddler free for you to use to contain any notes you want to make about each event.

Let me know how it goes…

-e

1 Like

@EricShulman That works fine. And not having code in the Event tiddlers text field is really useful. Thank you so much for your help Eric.

One further question: Can you explain why, when I click on the colored bar at the bottom of a particular day in the calendar it shows many journal tiddlers rather than just the one for that day. See attached

Cheers, Rob

The list of journals is determined by first finding all tiddlers that have a “Journal” tag.

Then, to calculate the date for each journal tiddler, it uses the following filter logic:

  • if it has a journal-date field that contains an 8-digit YYYYMMDD value
  • else if the title of the tiddler contains a date string that can be parsed to derive an 8-digit YYYYMMDD value
  • else use the first 8 digits of the created field

Next, it checks to see if that computed 8-digit date value falls within the current year and month being displayed by the Calendar.

Finally, for each date popup, it lists all journal tiddlers for which the 8-digit calculated date matches the current 8-digit calendar date.

Note that the journal-date field only exists if the journal tiddler is created by using the Calendar date popup’s “edit journal” (pencil) button (or by using @TW_Tones excellent enhanced journal tools), and the title date parsing requires the custom TiddlyTools/Time/ParseDate filter operator. Thus, if neither of those dates are available, the Calendar’s getjournals() macro defaults to using the tiddler’s created date.

So, if you used the TWCore standard “New Journal” button to create your journal tiddlers and don’t have TiddlyTools/Time/ParseDate installed, they would all be listed on the date they were created, even if you manually entered the desired date into the title of each tiddler.

I recommend installing TiddlyTools/Time/ParseDate so the title dates can be parsed by the Calendar. Also, you should update your copy of TiddlyTools/Time/Calendar because I just now fixed a small “timezone offset error” in the way that the parsedate[] filter is used by the getjournals() macro.

Let me know if this fixes your issue…

-e

1 Like

Hi @EricShulman

I have done as you suggested; installed ParseDate, upgraded Calendar, changed the name of all the date fields to journal-date and event-date and everything appears to work perfectly.

Many thanks again for all your advice and for the explanations. Very much helps my understanding.

Apologies but I have one additional question: I have a tiddler called Future Events which has this code in it to display all future events to a set of criteria in fields day1 and day2.

''Future Events''

Select range to display future events

Day1=<$edit-text field=day1 size=1/><br> Day2=<$edit-text field=day2 size=1/>


<$list filter=[tag[Event]!days:event-date{!!day1}sort[]]-[!days:event-date{!!day2}]>
<$view field=time/>
<$link field="title"/><br>
</$list>

This works well but I am wondering how I can include future events that are listed in an event list tiddler called Recurring Events and which meet the same criteria.

Cheers, Rob

What does your “Recurring Events” tiddler contain? If you paste it here, I can try to work up some suitable code.

-e

....0206;Iona's birthday
....0213;Emma's birthday
....0213;Becca's birthday
....0220;My birthday
....0306;Osho's birthday
....0312;Elodie's birthday
....0430;Becca and Tobi's wedding anniversary
....0505;Deb's birthday
....0514;Colin's birthday
....0526;Kate's birthday
....0528;Pam's birthday
....0529;Keith's birthday
....0723;Jane's birthday
....0808;Fred's birthday
....0812;Nora's birthday
....0827;Kate and Keith's wedding anniversary
....1005;Aila's birthday
....1106;Christie's birthday
....1206;Steve's birthday

Cheers, Rob

@EricShulman Hi

Is the attached of any assistance

Cheers, RobRecurringEvents.json (723 Bytes)

The code was a bit tricky because we can’t use the days[] filter, which only works with dates that have been stored in individual tiddler fields. We also need to convert the .... in the recurring date data into actual year numbers so we can compare the dates. We need to do this for both this year and next year.

Give this a try:

!Future Events
Select range to display future events:<br>
Day1=<$edit-text field=day1 size=1/><br>
Day2=<$edit-text field=day2 size=1/>

!!!One-time events:
<$list filter="[tag[Event]!days:event-date{!!day1}sort[]]-[!days:event-date{!!day2}]">
<$view field=time/><$link/><br>
</$list>

!!!Recurring Events:
<$let day1={{{ [{!!day1}multiply[86400000]] }}} day2={{{ [{!!day2}multiply[86400000]] }}}
     today={{{ [<now YYYY0MM0DD>format:date[TIMESTAMP]] }}}
     start={{{ [<today>add<day1>format:timestamp[YYYY0MM0DD]] }}}
       end={{{ [<today>add<day2>format:timestamp[YYYY0MM0DD]] }}}
  thisyear=<<now YYYY>> nextyear={{{ [<now YYYY>add[1]] }}}>
<$set name=events filter="
   [[RecurringEvents]get[text]search-replace:g[....],<thisyear>]
   [[RecurringEvents]get[text]search-replace:g[....],<nextyear>]
  +[splitregexp[\n]]">
<$list filter="[enlist<events>]" variable=event>
   <$let date={{{ [<event>split[;]first[]] }}} desc={{{ [<event>split[;]rest[]join[;]] }}}>
   <$list filter="[<date>compare:date:gteq<start>compare:date:lteq<end>]">
      <$link to=<<desc>>><<date>> <<desc>><br></$link>
   </$list>
   </$let>
</$list>

Notes:

  • Calculate the values of day1 and day2 as milliseconds (there are 86400000 milliseconds in a day)
  • Calculate the starting date. To do this, get today’s date (YYYY0MM0DD) and convert it to a “Unix Epoch” timestamp (number of milliseconds since Jan 1, 1970). Then, add the day1 value and convert the result back into YYYY0MM0DD format. We use the timestamp conversion so we can do simple decimal math to add date related values. In this way, the calculation and conversion automatically handles varying days per month as well as leap years.
  • Do the same to calculate the ending date
  • Next, get the year numbers for this year and next year
  • Read the text from RecurringEvents and replace the .... year “placeholders” with the values for thisyear and nextyear and split on the newlines to get a list of separate event items
  • Then, for each separate event item:
    • Get the YYYYMMDD portion of the item (the part before the semi-colon) and the description portion of the item (the part after the semi-colon)
    • Check to see if the date is between the calculated start and end dates.
    • If it is, then output a link to the description text, showing both the date and description.

Give it a try and let me know how it goes…

enjoy,
-e

1 Like

Hi @EricShulman

That is perfect. Thank you very much for your help.

As it is getting late here in the UK I will try and make sense of the logic and the code tomorrow.

Cheers, Rob