How can I calculate the time (minutes and seconds) to a daily recurring point of time in a schedule *new*: and update it as a countdown

For my classroom tools I look for a tool to calculate the rest of the current lesson. I would like enter these basic timetable as indexes. Do you have good ideas or examples?

So a countdown timer to Wednesday afternoon maths?

A countdown timer to end of 1st, 2nd, 3rd… lesson/block every day math

Check TiddlyTools for TW5 v5.3.0 — Small Tools for Big Ideas!™
you can set one or multiple alarms to run daily and to trigger on a condition that you can set using filters

Hi @EricShulman 's collection is great, but I do not need alarms - I need a countdown

Maybe https://tiddlytools.com/##TiddlyTools/Time/CountDown

Thank you @twMat, but I want

…and this automatically scheduled every day

In the last thread on time there was the proposition to use the Unix time which seems to be possible natively since 5.3. How can I convert a date to Unix time, I could not find the documentation yet

Given a date in 17-digit system format (YYYY0MM0DD0hh0mm0ss0XXX using UTC), you can convert it to “unixtime” using format:date[TIMESTAMP] and convert it back to a formatted date string using format:timestamp[...] where “…” specifies a TWCore date format.

See the 4th example here: https://tiddlywiki.com/#format%20Operator%20(Examples)

Get the date and time exactly 24 hours (86,400,000 milliseconds) from now:
[<now [UTC]YYYY0MM0DD0hh0mm0ss0XXX>format:date[TIMESTAMP]add[86400000]format:timestamp[DDth mmm YYYY 0hh:0mm:0ss]]
1 Like

Thank you @EricShulman for the help:
Given times in the form of 0hh0mm in a schedule in a dictionary tiddler “Testschedule” this code works:


\define timeregexp() (\d{2})(\d{2})
\function unixseconds()
[<now YYYY0MM0DD0hh0mm0ss>] [[000]] +[join[]format:date[TIMESTAMP]]
\end


<$list filter="[[Testschedule]indexes[]sort[title]compare:number:gt<now 0hh0mm>limit[1]]" >

*{{{ [{!!title}search-replace::regexp<timeregexp>,[$1:$2]] - [[Testschedule]getindex{!!title}]}}}
*{{{ [<now YYYY0MM0DD>] [{!!title}] [[00000]] +[join[]format:date[TIMESTAMP]] +[subtract<unixseconds>divide[1000]] }}}
</$list>

Here is a set with Testschedule to play around with;Schedule filter set.json (926 Bytes)

What is the smartest way to update this so that the countdown works?

More elegant using functions:

\function nexttime() [{$:/config/classroom!!schedule}indexes[]sort[title]compare:number:gt<now 0hh0mm>limit[1]]
\function timedisplay() [<nexttime>search-replace::regexp<timeregexp>,[$1:$2]]
\function scheduleinfo() [{$:/config/classroom!!schedule}getindex<nexttime>]
\function to-hours() [<seconds>divide[3600]floor[]] [<seconds>remainder[3600]divide[60]floor[]] [<seconds>remainder[60]] +[join[:]]
\function seconds()  [<now YYYY0MM0DD>] [<nexttime>] [[00000]] +[join[]format:date[TIMESTAMP]] +[subtract<unixseconds>divide[1000]] 
\define timeregexp() (\d{2})(\d{2})
\function unixseconds()
[<now YYYY0MM0DD0hh0mm0ss>] [[000]] +[join[]format:date[TIMESTAMP]]
\end

<<timedisplay>> <<scheduleinfo>>

<<nexttime>>

<<seconds>>

<<to-hours>>