Current date as tiddler title

I wanted to create a button that would set the current date as the title of the current date.

So, I wrote:

\define newInformationAction()
<$action-sendmessage
    $message="tm-new-tiddler"
    title=<<dateTime "YYYY-0MM-0DD ddd">>
    tags="Information"/>
\end

<$button class=<<tv-config-toolbar-class>> selectedClass="tc-selected" tooltip="New Information" actions=<<newInformationAction>>>
  {{$:/core/images/list-bullet}}
</$button>

This does not work. I think the error is in setting the title. But I am not able to figure out the error.

How do I set things right here?

There is no “datetime” macro. The name of the macro for formatting the current time as text is called “now”.

So, you want to write: title=<<now "YYYY-0MM-0DD ddd">>

-e

1 Like

Thanks, @EricShulman.

One more question. This leads to the title selected. So, anything I key in will replace the title.

Can I have the cursor immediately after the ddd? So, the cursor will be at * in ‘2021-08-30 Mon *’

One more question. This leads to the title selected. So, anything I key in will replace the title.
Can I have the cursor immediately after the ddd? So, the cursor will be at * in ‘2021-08-30 Mon *’

There is a configuration setting for which field gets the initial focus (see Default focus field for new tiddlers, which can be set from the $:/ControlPanel, Info, Basic tab). The default value for this setting is “title”, which results in the title text being selected as soon as the editor is displayed.

Unfortunately, there is currently no way to automatically set the initial cursor position to the end of the text within the title field. However, after the field contents are selected, you can immediately press right-arrow or end to move the cursor to the end of the title text. So, while it is not automatic, it is just one keystroke away.

-e

@EricShulman Thanks. Initial focus explanation reminded me that ‘everything is a tiddler’. And yes, unselecting the text is just one keystroke away :slight_smile: