How to get the current (dynamic) date/time as state for the <$reveal> widget?

56 views
Skip to first unread message

Hubert

unread,
Sep 12, 2018, 10:53:56 AM9/12/18
to TiddlyWiki
Hi all,

I'm trying to perform some actions based on the time of day. I'm unable to get the current date/time without resorting to a button push that sets a timestamp in a field that will serve as the state for the reveal widget.

Is there a way for the state text reference to automatically update or at least get wikified? When I place <<now hh>> in my state tiddler, the reveal widget only returns a match if "<<now hh">> is referenced directly. Matching <<now hh>> as a state tiddler value with a "12" for the time returns nothing.

Here's my code (one that involves a manual refresh button). I would be grateful for suggestions. Thank you!

\define RefreshButton()
<$button actions=<<RefreshButtonAction>>>
Refresh</$button>
\end

\define RefreshButtonAction()
<$action-setfield $field="timestamp" $value=<<now hh>>/
>
\end

<$reveal state="!!timestamp" type="gt" text=12>
It's after noon
</$reveal>

<<RefreshButton>>

Best regards,
Hubert


Eric Shulman

unread,
Sep 12, 2018, 11:42:06 AM9/12/18
to tiddl...@googlegroups.com
On Wednesday, September 12, 2018 at 7:53:56 AM UTC-7, Hubert wrote:
I'm trying to perform some actions based on the time of day. I'm unable to get the current date/time without resorting to a button push that sets a timestamp in a field that will serve as the state for the reveal widget.
Is there a way for the state text reference to automatically update or at least get wikified? When I place <<now hh>> in my state tiddler, the reveal widget only returns a match if "<<now hh">> is referenced directly. Matching <<now hh>> as a state tiddler value with a "12" for the time returns nothing.

Instead of using the "state" param, use the "default" param.  This param allows you to specify the state value using a variable, instead of a stored tiddler field value.

Thus:

<$reveal default=<<now hh>> type="gt" text=12>
It's after noon
</$reveal>


enjoy,
-e
Eric Shulman
TiddlyTools.com: "Small Tools for Big Ideas!" (tm)
InsideTiddlyWiki: The Missing Manuals

Hubert

unread,
Sep 12, 2018, 11:48:52 AM9/12/18
to TiddlyWiki
Just what I was looking for, absolutely amazing and simpler than I thought. Thank you Eric!
Reply all
Reply to author
Forward
0 new messages